[H-GEN] Useful not so obvious tips
Byron Ellacott
bje at apnic.net
Mon Oct 25 19:15:33 EDT 2004
Michael Anthon wrote:
> belial:~# find . -name file\* -print0 -maxdepth 1 | xargs -0 -i ls {}
> ./files.txt
> ./file with spaces
> Does them one at a time (useful is the program only takes one argument)
At this point you're not getting any benefit out of xargs, since you're
invoking ls once per file. You may as well use the -exec option to find
and be done with it. :)
You could also use:
find . -type f -printf '"%p" ' | xargs ls
But then any files with double quotes will not work. You could
similarly try for single quotes, with a similar problem. :) If you find
you're needing to use the -print0 and -0 options, you probably aren't
getting any benefit from xargs anyway.
I'm sure someone will correct me if I'm wrong. :)
--
bje
More information about the General
mailing list