Hear us Roar
Article:
 |
|
Hacking BSD, Part 1
|
| Subject: |
|
A tip to make one hack less ugly |
| Date: |
|
2004-06-23 01:31:51 |
| From: |
|
binary
|
|
|
|
The finding words section contains a really ugly hack. Adding /dev/null to the arguments of grep to force it to print the filenames along with matches is _not_ the way to go!
Everey *BSD grep I know of has a command line switch to do this. It's -H in FreeBSD and NetBSD and -o in OpenBSD.
And anyway, what's on earth
Fortunately, find's -exec switch allows it to use other utilities, such as grep, without forking another process. is supposed to mean? AFAIK what actually happens is that find forks a process for every file found, and executes grep from that process.
Compared to something like
find -type f -print0 | xargs -0 grep 'word'
this seems to involve a lot of overhead.
I must admit i stopped reading at this point. Proove me wrong, and I may actually continue and in the end, buy the book.
Cheers,
m
|
|
| |