creating pipes in find(1) - (nf)

johnl at cca.UUCP johnl at cca.UUCP
Thu Oct 4 13:42:40 AEST 1984


#R:sri-arpa:-1237800:ima:19700001:000:496
ima!johnl    Oct  3 10:25:00 1984

> How do I build a pipe within the exec portion of find?
> Example:
> 	find /etc -name printcap -exec cat {} | lpr \;

The short answer is that you can't -- find uses an exec() call to
run what it runs, and exec won't create pipes.  Any "|" characters are
handled by the shell.  In the Bourne shell, though, you can do stuff like
this:

	find /etc -name foo - print | while read fn do
	 cat $fn | lpr
	done

I suppose that there's some way to do that in the C shell, too.

John Levine, ima!johnl



More information about the Comp.unix mailing list