Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

Monday, August 08, 2011

Bash function of the day

I push the command line on people, because it's generally the most efficient way to do several different things. My devs resist me, although I don't understand why... part of it is that most places I've worked at are Windows houses. No problem, say I: Cygwin to the rescue. Seriously, gang, I'm not just making this up.

(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"
}