Windows batch file - string comparison with wildcard -
i have file myfile.txt
bunch of strings. wrote following batch file loop through lines, , print line if equals specific string (for sake of demo, choose string foo
):
@echo off setlocal enableextensions enabledelayedexpansion /f %%i in (myfile.txt) ( line=%%i if !line! equ foo* ( echo !line! ) )
in application, not need print lines match foo
, lines match foobar
, foobarfred
, foofred
, ... that's why put wildcard there.
but doesn't work..
please help.
findstr /b "foo" myfile.txt
/b
: line should start string
also might useful:
/i
: ignore capitalization (find foo, foo, foo, ...)
see findstr /?
more options
Comments
Post a Comment