recursive grep

Leslie Mikesell les at chinet.chi.il.us
Fri Sep 1 13:49:46 AEST 1989


In article <191 at titania.warwick.ac.uk> cudcv at warwick.ac.uk (Rob McMahon) writes:
>Re: `find ... -print | xargs' and filenames with spaces/newlines.

>>Well, how would you go about parsing filenames out of a list if you can't use
>>spaces or newlines as the delimiters?

>Spaces should be no problem.  Find prints it's filenames separated by
>newlines, and xargs should have an option which means take each line of input
>literally as a single argument, *not* ignoring spaces anywhere.

It's a can of worms any way you turn it.  You could intersperse a filter
between find and xargs to quote the filenames in the ways acceptable
to xargs.  However, this is non-trivial since the names might contain
instances of any or all of the quote characters and it is still imperfect
since you can't tell newlines in the filenames from those added by find.

>It would be useful if find quoted each newline in a filename with a backslash.

But then what do you do about literal backslashes (which can already be a
problem if you let xargs or the shell parse them)?

I'd like my commands to do the same thing whether typed to the shell,
exec'ed, xarg'ed or even handled by shell scripts that do things like
"eval set $*".   That means I don't want any *?[\"'space/newline(etc.)
metacharacters in my filenames, or even any leading "-"'s. 

How about a hook in the file system switch to allow arbitrary character
translations in filenames?  Perhaps it could be above the RFS/NFS links
so if you mount someone else's filesystem you can still make it look
the way you prefer.

Les Mikesell



More information about the Comp.unix.wizards mailing list