[Sussex] Future Talk [Was: Label and partition external hard drive]
Dominic Humphries
linux at oneandoneis2.org
Wed Mar 2 10:18:12 UTC 2011
> I've said it before but I will say it again: The power of the CLI comes
> from chaining commands together!
>
> $ ps -ef | grep ^user | grep program | awk '{print "kill " $2}' | sh
>
> There! A one line script to find a set of processes run by the same
> user account and kill them. I took me a couple of minutes to build the
> script up, bit by bit more or less as I did above on site live.
Another example that I use about a hundred times a day is this:
function vai {
found=`find . -path *$1 | grep -v blib | grep -v cache | grep -v .svn`
vi $found
}
It lives in my .bashrc and gives me a new command, 'vai'
What this does is search all your working directory's subdirs. for the filename you specify. So instead of having to type:
vi really/long/and/annoying/path/name/to/the/file/I/actually/want/to/edit.txt
I can just type
vai edit.txt
Since there are dozens of files in all kinds of paths that I frequently need to edit, something as simple as this makes a huge difference to how quickly I can make edits. Especially when I know the filename I want but am not entirely sure of where exactly it is..
The "find" gets the full pathname of matching files; The 'grep -v' parts strip out directories I don't want to look for files in.
If there's any GUI way to open files by name without having to specify the path, I would love to know about it.. It'd beat the hell out of all the double-clicking on folder icons :o)
Dominic
More information about the Sussex
mailing list