grep --dont-read-devices-or-symlinks

Simon 'corecode' Schubert corecode at
Fri Jun 17 08:48:26 PDT 2005

On 17.06.2005, at 17:39, Matthew Dillon wrote:
:find attached a patch to grep to only read real files, ignoring 
:devices, etc.(-O --only-files). I felt I need this for grepping my 
:which also contains some compile/* directories where modules produce 
    Well, there is at least one issue with this.  I'm not sure the 
option is
    general enough.  e.g. perhaps it should not avoid symlinks.  I'd 
    stat() rather then lstat() at the very least.
the main purpose of this is to avoid symlinked directories, but I 
thought going a little bit more general and ignoring anything 
non-regular would be better in the end.

    Grep isn't realliy the best utility to search an entire hierarchy.
    I would use a comnation of find with the -exec option to write
    a search script.
For sophisticated stuff yes, but I just wanted a quick hack to "just 
grep -Or /sys $foo"

Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low $$$ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |      Against  HTML   \
Dude 2c 2 the max   !       Mail + News   / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00004.pgp
Type: application/octet-stream
Size: 186 bytes
Desc: "Description: This is a digitally signed message part"
URL: <>

More information about the Submit mailing list