|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Alexander Hall (alexander
beard.se)
Date: Fri Feb 22 2008 - 06:07:55 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Janne Johansson wrote:
> a.velichinsky
gmail.com wrote:
>>>> For instance 'ggrep -r ...' instead of 'grep -r ...' to search
>>>> recursively
>>>> with gnu grep (a worthless feature imho).
>>> Displaying the name of the file and the matched line nicely like grep -r
>>> does is not elegant with find + grep without using a script or a long
>>> and inelegant alias - or if it is, I'd be interested in how it can be
>>> done in case I need to work on some ancient unix.
>>
>> $ find DIR -type f -print0 | xargs -0 grep PATTERN
>>
>> which, unlike 'find ... -exec' is just as fast as 'grep -r', and unlike
>> 'grep -r', will skip special devices, symlinks, etc.
>>
>
> # uname -a
> SunOS dumbhost.test.se 5.10 Generic_118855-33 i86pc i386 i86pc
> # find /etc -type f -print0
> find: bad option -print0
> find: [-H | -L] path-list predicate-list
>
> But yes, its probably bad to start one grep per file.
$ find /etc -type f -exec printf "%s\0" {} \;
(if they've got printf, that is :)
I'd guess a printf process has less startup overhead than grep.
But, uh-oh... Does solaris have "xargs -0"? :-)
/Alexander
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]