[H-GEN] bash command-line question [was: Re: ...self executing tar.gz's?]
Greg Black
gjb at gbch.net
Wed Jun 12 06:29:02 EDT 2002
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
Tony Nugent wrote:
| On Wed Jun 12 2002 at 14:43, Greg Black wrote:
|
| > 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.
I'm not familiar with the documentation you actually used, but I
would think that most of the find man pages I have seen are in
fact quite clear -- for their intended purpose. Remember, man
pages are really references for people who know what's what and
just need a reminder of the specific syntax.
That being said, I'm aware that many people end up using them as
tutorials, and feel let down by their lack of utility for that
purpose. There are a couple of possible solutions for that.
One is to find a "good book" on Unix that will introduce many of
the Unix utilities and suggest ways of using them.
Another possibility might be to run a bit of a tutorial at a
Humbug meeting that might have a general introduction to the
best ways to extract information from man pages, followed by
specific coverage of pages that audience members requested. I
wonder if people would be interested in such a session?
| 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 :-)
I'd point out, for completeness, that `-a' is generally not
needed as an explicit operator -- if you look at my example
above, it could have been written as:
find . -type f -a -name \*.txt -a -exec cmd1 {} \; \
-a -exec cmd2 {} \;
The `-a' (and its modern equivalent `-and') is "just understood"
where operators are concatenated, although many versions of the
man page gloss over this, although they usually show it in their
examples.
Greg
--
* 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