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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -