[H-GEN] bash command-line question [was: Re: ...self executing tar.gz's?]
Tony Nugent
tony at linuxworks.com.au
Wed Jun 12 04:35:36 EDT 2002
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
On Wed Jun 12 2002 at 14:43, Greg Black wrote:
> | $ find . -type f -name \*.txt -exec command1 {} ; command2 {} | filter_prog \;
>
> Your syntax is a bit broken.
heh, sure is:)
> The usual approach for the multiple command part is this:
>
> find . -type f -name \*.txt -exec cmd1 {} \; -exec cmd2 {} \;
Ah. cool. And indeed it works as advertised.
It didn't occur to me to repeat the -exec parameter like that. I
had been regarding the `\;' as the termination of the find command
itself, and not just the -exec expression part. Subtle difference
(and it does explain the real meaning of the error message "find:
missing argument to -exec"). Thanks, I can put this to some very
good use :-)
While it has been there in /usr/bin "forever", find is a weird
command (as in "not well explained/understood"), the man and info
(yeech) pages should give lots more examples imho. It was only
relatively recently when I tripped over some good examples of it
being used with the `-o', `-not' and `-a' parameters to group
expressions (eg "-name \*.txt -o -name \*.TXT") - which for me gave
this command a new breath of life :-)
Clinton's (pre-caffeine) idea of using a subshell also has some good
possibilities (post-caffeine verified that it does work:-)
> find . -type f -name \*.txt -exec sh -c 'command {} ; command2 {} | filter_prog' \;
I can use that too. Much cleaner to implement than on-the-fly shell
scripts, but it does have the added expense of running an addition
subprocess (usually no big deal).
This is great, two solutions and I only asked for one. Beers all
round!
Cheers
Tony
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'. See http://www.humbug.org.au/
More information about the General
mailing list