Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do all that at once with find:</p> <pre><code>find /usr -type d -name My\ Files -exec rsync -avR '{}' /iscsi \; </code></pre> <p>For more info <code>man find</code>, right before the end there are several examples. Alternatively you can pipe the results using the <code>xargs</code> utility.</p> <p>You should explore your manuals more througly, there is a lot of treasure to be found.</p> <p>On a bash script you could also put:</p> <pre><code>export MIVARIABLE=$(find /usr -type d -name My\ files) </code></pre> <p>and then </p> <pre><code>for i in $MIVARIABLE ;do rsync -avR $i /iscsi; done </code></pre> <p>But this has drawbacks among them if your results are very big, it may exceed bash maximum text space available for a variable , and if the retrieved names include spaces, some utilities may go crazy.</p> <p>In a modern system the maximum size on a bash environment variable can be from 8kib to nearly 2MiB, if you put to much info on a variable you'll get a <code>Argument list too long</code> error.</p> <p>So if you need to iterate over a file/directory list you better use find built-in functions or in cooperation with <code>xargs</code>. Read carefully their manuals and try some dry runs using <code>echo your_command_line</code> instead, so you gain appropiate experience and confidence with the utilities. Look for the <code>-print0</code> function on <code>find</code> as well as the <code>-0</code> command on <code>xargs</code> which are designed to avoid some problems with filenames with spaces and symbols in their names.</p> <p>EDIT: <code>find</code> will handle white spaces correctly with the -exec operator:</p> <pre><code>find /usr -type d -name My\ Files -exec rsync -avR '{}' /iscsi \; -exec rm -rf '{}'\; </code></pre> <p>would do what you need one after the other. I was pointing out options, so you could decide what was better suited to your needs, I did not meant to confuse you.</p> <p>Edit2:</p> <pre><code>find /usr -type d -name 'My Files' -exec rsync -avR '{}' /iscsi \; -exec rm -rf '{}'\; </code></pre> <p>funciona igual que el ejemplo de arriba. Cuando bash lee 'My Files' it takes the whole word togheter and does not treat the white spaces inside differently</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload