[H-GEN] Useful not so obvious tips
Greg Black
gjb at gbch.net
Tue Oct 26 00:54:30 EDT 2004
On 2004-10-26, Byron Ellacott wrote:
> 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. :)
I'm not sure if you're wrong because I'm not sure what you see
as a benefit. But the example I'd use is when searching my
wife's email archives for something that she can't find. It has
file names with spaces, single quotes and double quotes and is
tricky to search without using -print0 and -0. I use something
like
find . -type f -print0 | xargs -0 grep -l stuff
Then I adjust stuff until it narrows it down to a likely set of
file names and then do
find . -type f -print0 | xargs -0 grep -l newstuff | xargs -0 less
Of course, the above also involves use of the up-arrow to
retrieve previous commands for minor editing, so it's less
typing than it looks and tacking the final four tokens onto the
end of the line is burned into my finger memory.
Or were you talking about some other benefit than operating on a
(possibly large) list of files?
Cheers, Greg
More information about the General
mailing list