[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep.... I know I am new to ubuntu but....
From: |
Bob Proulx |
Subject: |
Re: grep.... I know I am new to ubuntu but.... |
Date: |
Thu, 9 Feb 2012 02:09:10 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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