I Use This!
Low Activity

Ratings and Reviews : Listing

Denilson Sá says:
Find and xargs  
4.0
   
written about 16 years ago

'find' is a great tool, really powerful and useful.

'xargs', however, looks like a promising tool but I rarely use it because it is cumbersome to use. Basically, since the default behavior reads items separated by whitespace, 'xargs' is very difficult to use with filenames that might contain spaces. I know there must be some set of parameters to fix this, but then its use becomes less straightforward. Even the manpage recognizes this: "Because Unix filenames can contain blanks and newlines, this default behaviour is often problematic"

For this reason, I've never used xargs in years.

If I need to run something for multiple files, I do this (in bash):

for a in * ; do something "$a" ; done

Which is easier to read and to write (although slightly verbose).

Another option is this:

some | commands | here | while read a ; do something "$a" ; done

Finally, I can also just use the -exec parameter from 'find'.

0 out of 1 users found the following review helpful.
Did this review help you? |