(I'll grant, however, that there are some Finder/Explorer replacements that wrap up some of this functionality pretty nicely in a GUI, including having a command line in whatever directory is open--but it's still a command line, and you still should know how to use it.
Two things I do a lot from the command line are find files, and find files containing a pattern. Here's two drop-dead simple Bash functions that do this. Seriously, doesn't get much easier.
function fn {
find . -type f -name "$1"
}
function fng {
find . -type f -name "$1" | xargs grep "$2"
}
find . -type f -name "$1" | xargs grep "$2"
}
2 comments:
If "fn" is "find" what is "fng"?
Also have you heard about/seen ack -> http://betterthangrep.com/?
Effin' New Guy?
find-grep. Yeah, I have ack, and could wrap it up in a function too. The raw command to search *.rb files for 'model' would be:
ack -r -G '\.rb$' model
I'd rather use globbing for naive filenames, I guess.
Post a Comment