[ale] Bash question: | in find

Danny Cox danscox at mindspring.com
Fri Jan 24 11:11:15 EST 2003


Joe,

On Fri, 2003-01-24 at 15:28, Joe wrote:
> Yes, in this particular instance. But more generally, I want
> to know how to execute a pipeline (as opposed to a single
> command) in an "-exec" clause in a "find" command.

	I was about to say: "you can't".  But you can invoke a shell script
with -exec.  There *may* be a way to do it on the command line using sh
-c, or perl perhaps.  It's still a bugger because it's being interpreted
at least thrice, twice by a shell, and that gets confusing fast.

	Here's something that works for me (just an example):

find /home -type d -exec /bin/sh -c 'echo {} | cat' \;

one caveat: GNU find replaces '{}' anywhere it finds it.  Other finds
(Solaris, perhaps?) will only replace '{}' if it's by itself.  That's
trickier than it sounds (e.g. I've not been able to make it work on
Linux yet).

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list