Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!warwick!alfie From: alfie@cs.warwick.ac.uk (Nick Holloway) Newsgroups: comp.unix.wizards Subject: Re: recursive grep Message-ID: <1976@diamond.warwick.ac.uk> Date: 5 Sep 89 09:32:57 GMT References: <13710@polyslo.calpoly.edu> <144000002@cdp> <2390@auspex.auspex.com> <9408@chinet.chi.il.us> <191@titania.warwick.ac.uk> <9440@chinet.chi.il.us> <25420@iuvax.cs.indiana.edu> Sender: news@warwick.ac.uk Reply-To: alfie@cs.warwick.ac.uk (Nick Holloway) Organization: Computer Science, Warwick University, UK Lines: 42 In article <25420@iuvax.cs.indiana.edu> sahayman@iuvax.cs.indiana.edu (Steve Hayman) writes: > > Much discussion of problems with filenames containing embedded > > newlines or spaces. > [ Steve suggests modifying find and xargs to separate filenames by '\0's ] > > If you wanted a really secure find | xargs combo, perhaps this > would help. Perhaps, while we are adding new predicates to find, we could just cut out the middle man, and implement a new -xargs flag. e.g: find / -name core -xargs rm -f \; There would (should?) be no problems with spaces/newline et al., since `find' would build the args to be passed to exec*() directly [leave the shell out of it], and even the command for xargs could have spaces in, by doing find ... -xargs "o o" \; I admit that you do not have the control you do with the standard xargs, but I believe that this would be satisfactory for the majority of uses. Hopefully this would not have the misfeature (bug) that the xargs here has. Even if no files are given, the command will be executed. (This also applies to the scripts posted). echo "/" | xargs ls # performs 'ls /' cat /dev/null | xargs ls # performs 'ls' - wrong! I used to wonder why my tidyup script kept producing errors from rm, until I discovered this. Now I use the more innefficient "-exec \;". If I were given a -xargs flag, I would use it. (Also if the internal -ls printed set[ug]id etc correctly - I would use that instead of the "-exec ls {} \;") -- JANET : alfie@uk.ac.warwick.cs | `O O' | Nick Holloway BITNET/EARN : alfie%uk.ac.warwick.cs@ukacrl | // ^ \\ | Comp Sci Dept INTERNET : alfie%cs.warwick.ac.uk@nsfnet-relay.ac.uk | Uni of Warwick UUCP : ..!mcvax!ukc!warwick!alfie, alfie@warwick.UUCP | Coventry, UK.