views:

25

answers:

2

Windows XP Pro

This shows output in the console:

dir | find " free"

This doesn't:

tasklist | find "Image Name"

This does:

tasklist | find /C "Image Name"

And this does write the expected line into the file:

tasklist | find "Image Name" > foo.txt

What causes that?

A: 
> tasklist | find "Image Name"
Image Name                     PID Session Name        Session#    Mem Usage

Can't reproduce here. Your second command line does work as expected and that way no confusion arises when the fourth one writes that line into a file.

Did you perhaps still have the leading space in the string to search from the previous line when you searched for " free"?

Joey
I executed exactly what is seen in the question. I had a second pair of eyes examine what I was doing before I brought the question here, and I was very careful to make sure the question was representative. I'm sure it's some Console oddity on this end. Very strange.
lance
A: 

what about findstr? have you tried?

C:\test>tasklist  | findstr "Image Name"
Image Name                   PID Session Name     Session#    Mem Usage
ghostdog74
Yeah, I think that worked, but the actual need I'm after uses the /C flag of find.
lance