Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is there any way to return a list (directory listing, for instance) and EXCLUDE certain entries in the returned list based on specific parameters?
For instance, let's say I ran a "netstat" command to see the current active connections to my machine. I might get 5 entries, for instance, 2 of which are private IP connections from other PCs, and 3 from HTTP sites. If I'm only interested in returning ONLY the 2 private IP connections in the list, is there a command or method I can use to achieve this? In other words, I'd like the returned list to ignore or filter out all the HTTP selections.

You can achieve such goals with the FOR command, using its /F switch.
In the example you've given, this would only display the non-http IPs:
for /F "tokens=*" %%A in ('netstat') do (
echo %%A|FIND /I ":http" > nul
if errorlevel=1 echo %%A
)I'm not going to write a tutorial about the command for you, but you can get almost all the information you need on its own documentation: on the command prompt, type "FOR/?".
Keep in mind that the FOR cmd does only have this "advanced features" like the /D /F /L and /R switches on NT systems (Windows NT, 2000 and XP), not on Win9x nor DOS.
If any questions come up as you study the command (there isn't much to learn, it's not a cmd like SED), ask them on this forum!
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |