recursive grep

Nick Holloway alfie at cs.warwick.ac.uk
Tue Sep 5 19:32:57 AEST 1989


In article <25420 at iuvax.cs.indiana.edu> sahayman at 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 at uk.ac.warwick.cs               |  `O O'  | Nick Holloway
BITNET/EARN : alfie%uk.ac.warwick.cs at ukacrl        | // ^ \\ | Comp Sci Dept
INTERNET    : alfie%cs.warwick.ac.uk at nsfnet-relay.ac.uk      | Uni of Warwick
UUCP        : ..!mcvax!ukc!warwick!alfie, alfie at warwick.UUCP | Coventry, UK.



More information about the Comp.unix.wizards mailing list