Re: grep.... I know I am new to ubuntu but....

Bob Proulx <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
John Cowan wrote:
> I'm aware of this extension to classic find syntax.  However, I still
> like to use xargs because it allows pipelines to be generalized like this:
> 
>     find some/path | grep 'some.*regex' | xargs -d'\n' grep 'some-string'
> ...
> grep exactly those files.  This allows searches which can't easily be
> expressed by arguments to 'find', ...

I admit that it is a rather nice paradign.  And again I never use
whitespace in filenames so it always works perfectly for me.

But now I have to point out the GNU find -regex option. :-)

  find some/path -regexp 'some.*regex' -exec grep 'some-string' {} +

The only gotcha is that the regular expression must match the entire
pathname.  It is anchored on both ends.  So use of .* is usually normal.

But of course -regex is an extension and so isn't portable everywhere.

Bob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.