Wednesday 25 May 2011

Useful .profile scripts!

Well, I've only written one so far, but it's ultra helpful and saves you remembering all the options you need to pass to standard commands to do what you want. If anyone else feels like commenting with their time-saving commands, maybe I'll build up a library of them.

Here goes :-

files_with - Find files containing a string inside the current directory, recursively


files_with() { grep -H -n "$*" ./* -R | cut -d: -f1 -f2; }

$ files_with hello
./blah.txt:4
./sub/blah.txt:6

No comments:

Post a Comment