[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: searching inside files with find, cat and grep as a oneliner ...



Albretch Mueller wrote:
> $ find -name '*.extension' -exec grep -H 'pattern' {} \;

Using {} \; is the old way.  That invokes grep once per file.  That
works but is slower and less efficient than it could be because it
takes a little bit of time to launch grep.

But newer POSIX standard find can use a {} + to launch grep once and
to pass as many files on the command line as the system allows.  That
is faster since grep is launched only as many times as needed.
Usually only once.

  $ find -name '*.extension' -exec grep -H 'pattern' {} +

As a benefit you don't need to escape the + since it isn't a special
character to the shell.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: