Path: utzoo!utgpu!watmath!att!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.wizards Subject: Re: recursive grep Message-ID: <9440@chinet.chi.il.us> Date: 1 Sep 89 03:49:46 GMT References: <13710@polyslo.calpoly.edu> <144000002@cdp> <2390@auspex.auspex.com> <9408@chinet.chi.il.us> <191@titania.warwick.ac.uk> Reply-To: les@chinet.chi.il.us (Leslie Mikesell) Organization: Chinet - Public Access Unix Lines: 32 In article <191@titania.warwick.ac.uk> cudcv@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