Saturday, October 9, 2010

Equivalent of Unix’s ls –lah | grep something for Windows

Hello, ever since I am using linux based platforms I loved them for the rich command shell. It’s been very easy for me to find what I am looking for using command piping and the grep command. A very common combination that I’ve been through is “ls –lah | grep something”, which searches for specific file in current folder. Or “ps –ax | grep processname” which searches for specific processanme in the list of all running processes. Recently I had to, on Windows OS, very often run “netstat –an” to search whether specific port is occupied and by which executable. However that Windows OS is Windows Server, and it has lots of services running, so finding a specific port was terribly hard. A quick search gave me desired result.

You can use Windows’ command “find” exactly the same way you use “grep” in linux/unix! So finding a specific port occupation is like that:

netstat –anb | find “:80”

this will list all “:80” in the list, which basically means – all 80 ports occupied!

Great stuff!

No comments: