Find and Run Script
October 31st, 2008
I have a number of utility scripts I’ve written that I keep shared between all of my Linux machines. Mostly stuff to automate tasks I find myself regularly doing.
One such script is femacs, which is short for “find emacs”. More descriptively, the idea is to combine the call to search for a file with actually opening the file in emacs. The script is pretty simple:
1 | find -name $1 -exec emacs {} \; |
And it’s usage is what you’d expect:
1 | femacs index.jsp |
Despite it’s usage of the find command’s ugly syntax, it suffers from one very large flaw. If there are multiple files that match the given file name, they will all be opened in their own emacs process. It hasn’t been an issue since I’ve been careful to only use it when I know there is a single file I am looking for.
A coworker apparently was doing the same thing (except he is a vim user). He finally got tired of the limitation and took the time to make a much more robust version of the script. His blog entry on the change can be found here. It wouldn’t take much to adapt this to virtually any application you’d want to run with this sort of functionality.

