[CLUE-Cert] Sys Admin Test
Michael James Robbert
mrobbert at mines.edu
Fri Sep 21 16:05:20 MDT 2001
From the find man page:
-exec command ;
Execute command; true if 0 status is returned. All
following arguments to find are taken to be argu
ments to the command until an argument consisting
of `;' is encountered. The string `{}' is replaced
by the current file name being processed everywhere
it occurs in the arguments to the command, not just
in arguments where it is alone, as in some versions
of find. Both of these constructions might need to
be escaped (with a `\') or quoted to protect them
from expansion by the shell. The command is exe
cuted in the starting directory.
I use this all the time and I love it. I find that the common use of
-print is too limiting and I quite often want to execute an ls -l on the
files that I find. The {} gets replaced with any files that are found
and that command is executed. So your example would find all files name
core and then execute the command rm -f core. Then the \; is just
escaping the ; that is required after the command.
It is a little confusing at first, but if you use it as much as I do
then you begin to memorize it.
Sean LeBlanc wrote:
> I took the test today, and squeaked by with an 80%. Without
> going into details (since apparently I'm forbidden to
> "distribute questions and answers"), I'd like to ask about
> some syntax I'm not familiar with. One of the questions
> dealt with a command like this:
>
> find / -name core -exec rm -f{}\;
>
> I think I understand the first part, although I've never
> used the -exec flag with find. But the {}\; is what I
> don't understand. I might have the syntax incorrect: it's
> possible there was a space after rm -f and before the last
> part.
>
> BTW:
> Interestingly enough, there was more than one question on
> VNC. Good thing we went over some of it on Wed. I use it
> all the time, so the questions were gimmes (I think), but
> I can imagine it will be helpful to others that were there
> on Wed.
>
> Also, if we are going to talk about sendmail next time, maybe
> we could cover .forward, too? There was a question on this
> on the test, too, and I was pretty much clueless about it
> (other than its existence).
>
>
--
Michael "Murph" Robbert
System Administrator for Math/CS
Colorado School of Mines, Golden, CO 80401-1887
Office phone: 303-273-3786 Fax: 303-273-3875
Pager: 303-461-6543 or Text messages: murph_pager at bigfoot.com
Email: mrobbert at mines.edu
More information about the clue-cert
mailing list