Vista and Unix Together

May 6th, 2007

Whenever I need to find something, especially when I know it is there somewhere, the Windows search always lets me down. On a Unix system I can simply use the find command to get to the file I want quickly with a very specific search. I want that in Vista. Fortunately they do have Services for Unix on Vista. This includes various packages including the base Unix utilities and Perl. I am downloading it right now.

Once it is in place I can run the following command:

find . -name \*.cs -grep -li foo

That command will then list all of the C# source files which have the string "foo" in them. The command starts in the current directory specified by the initial period and then uses the -name option to filter the search candidates. Finally in runs grep on each file as it looks for a match. It does not require the files to be indexed and it will bypass reading every file it comes across. As I use the Vista search, even with the advance options, I am surprised to see I cannot filter by file extension. Next what I could do is run a command along with the find command.

find . -name \*.cs -grep -li foo -exec Notepad2.exe {} \;

I am not sure what that will do. I will need to have Notepad2.exe in my PATH environment variable which should be easy enough to set. That will open up all results in the text editor. I just better not do it when there are more than a handful of results.

Update: The above command does not work as it does on a more modern Unix system. Instead I had to run the following command:

find . -name \*.cs -exec grep -li foo {} \;

Comments are closed.