-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 El 2014-04-27 a las 22:54 -0400, Anton Aylward escribió:
On 04/27/2014 04:23 PM, Carlos E. R. wrote:
Then I use:
while read FILES ; do echo "$FILES" # or whatever. done < text_file_containing_list
OUCH! You need to be careful with that.
if you have a number of words on an input line the 'rest of the line" is assigned to the last variable of the line
So if the text file contained
onewordonaline twowords onaline three words onaline four words ona line five words on a line
then yes, you version would soa up all the words on the line But one that began
while read WORD WORD2 ; do echo "$WORD" .....
would produce
Wrote four five
Nope, it doesn't. Look for yourself: cer@minas-tirith:~/bin> cat test_while #!/bin/bash while read FILES ; do echo "$FILES" # or whatever. done < text_file_containing_list cer@minas-tirith:~/bin> cat text_file_containing_list onewordonaline twowords onaline three words onaline four words ona line five words on a line line with double and triple spaces cer@minas-tirith:~/bin> cer@minas-tirith:~/bin> test_while onewordonaline twowords onaline three words onaline four words ona line five words on a line line with double and triple spaces cer@minas-tirith:~/bin> Words are written correctly, and with the correct number of spaces. :-)
That is why I use the "-print0" or the -printf or the \{\} options with find and xargs
Well, see above, it works just fine. I'm intentionally not using WORD1 WORD2 etc. - -- Cheers Carlos E. R. (from 13.1 x86_64 "Bottle" (Minas Tirith)) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iF4EAREIAAYFAlNfEdYACgkQja8UbcUWM1yBdQD9EWexPEtRPmSRbN+JZfOVJXA+ H2Wmj9BRdfQEs6XPDJwA/jbzhjo9Zo3ft4c5Y6+3fjwfnYSfEYXJSboE897cb+RN =wF21 -----END PGP SIGNATURE-----