[NTLUG:Discuss] Re: Renaming a Linux host
Thomas Cameron
thomas.cameron at camerontech.com
Fri Jul 29 13:25:22 CDT 2005
> > find /path -type f | xargs grep "foo"
>
> I've had that command puke and die because the arg list to grep was too
> long. A better version is:
>
> find /path -type f -exec grep "foo" {} \;
>
> The -exec flag executes the following command once for each match found.
> The "following command" is terminated by a ;, so you have to escape the
> ; from the shell so find will see it. The string {} is replaced by the
> thing that was found. Also specifically grepping something out of a
> file, I'll use the -l option to grep to just list the files that
> matched. I'll then grep/edit the interesting sounding files that it
> finds. This prevents matches from spewing across your screen faster than
> you can read them.
>
> =-= Robert Thompson
Yup - as with most thing F/OSS, there is more than one way to skin a cat.
:-) That syntax has never tanked on me, but I can see where it would.
Thanks for the info though, I will probably steal^H^H^H^H^H borrow that
syntax.
Thomas
More information about the Discuss
mailing list