- a better directory recall
- The '...' (and beyond) facility for changing directories upwards an arbitrary number of parents
- a directory database
- A much easier to use "FOR" facility from the command line
- The FFIND /S command, which recursively searches for text in files
I knew about grep's -R flag, but found it hard to use and couldn't figure out how to recursively search just .h files, for instance. I finally broke down and read the man page, and here's what I found out.
To recursively search for something, you can use the -R flag to grep:
$ fgrep -R BIGENDIAN .
To recursively check just .h files:
$ fgrep -R --include="*.h" BIGENDIAN .
Where:
fgrep - "fast" grep. You can use this if you don't use any regexps in the search pattern
-R - recursively search folders, starting with this one (.)
--include="*.h" - just include *.h files. You need to put the quotes around the wildcard, or the shell will try to expand it and it won't work like you think. That's why you can't just do:
$ fgrep -R BIGENDIAN *.h
It will still just search local .h files, because the shell expands the wildcard before fgrep gets it. So if there are two .h files in the current directory, the command looks like this after the shell gets done with it:
$ fgrep -R BIGENDIAN foo.h bar.h
You can add multiple --includes, and there's even a --exclude you can add to exclude files of that pattern from the search.
grep man page
No comments:
Post a Comment