The Command Prompt

This is going to seem like yesterday’s news to my fellow Mac OS X and Unix readers, but I just got something working today that is pretty impressive in the Windows command prompt.

I love this Windows version of “grep”—I install it on every server and desktop I interact with. It’s super fast, very similar to the Unix version, and I’ve never had a single problem with it.

I was trying to use its output as input for another command. This is called “command redirection” in the Windows world and “piping” everywhere else. Sadly, the documentation on the Web about this feature of Windows is sparse. I can see why: Windows executes both commands simultaneously and if the receiving command wasn’t designed to wait for standard input then it’ll just error out. Like the “del” command, for example. Non-Windows users are welcome to snigger quietly now.

Then I found this article. This isn’t piping per se, but the idea is the same. Take the output of one command and use it in another. Once I had that, it was a simple for /f "tokens=*" %a in ('grep -l stuffIwantDeleted *.FOO') do del %a. Worked like a dream!


%d bloggers like this: