FINDSTR Question

Toshiba Satellite l505d-s5965 notebook
April 4, 2010 at 17:40:43
Specs: Windows 7, 1024

if you
lets say the word ur looking for is Test
set /p ask=ask

FINDSTR /C:"%ask%" C:\Myfile

how come if you just type 'T' it guess it right away ? what am i doing wrong.

i would like to have it case senitive yet guess the whole name/words.

i read the Findstr /? still alittle lost.

how come

See More: FINDSTR Question

Report •

April 4, 2010 at 19:43:46
you can use "^pattern$" or better yet, you can download GNU grep for windows and use -o option

grep -o "word" file

GNU win32 packages | Gawk

Report •

April 4, 2010 at 20:26:29
sorry i kinda fallow but well yeah :) lol

Report •

April 4, 2010 at 20:45:09
ghost dog nailed it: you have to use "regular expressions".
findstr will always find "H" regardless if it's "H", "Hell!", or "Hello the house"
but humble Findstr can do limited version of RE:
findstr /r "\<Hello\>" ffile
will find the word in any line in the file. if you want
the entire line to be just the one word:
findstr /r "^Hello$" ffile

Report •

Related Solutions

April 5, 2010 at 05:39:08
findstr /r "^Hello$"

can you use a variable there? because i tried to use a variable it didnt work , wouldnt find anything. that was in the variable.

Report •

April 5, 2010 at 05:46:13
if you want to use variable, then try using the syntax for DOS batch variable %var% ..

GNU win32 packages | Gawk

Report •

April 5, 2010 at 06:59:30
thanks that worked,

now how could go about

find numbers? i mean like a IP address?

i mean find whole string and not just if the users typed 1 in the SET /P IP=IP: it would find the whole string and not error because they didnt type

that make sence?

Report •

April 5, 2010 at 07:43:54
i dont really want nothing 3rd party but either batch or VBS code to find exact strings, as descibe above.

is there a VBS code that replace FINDSTR that the results could be tossed back into a batch file?

ive search the internet nothing seen so far.

Report •

Ask Question