Couple of other questions.
1) Can't seem to put this into a FOR LOOP. I get the error
FINDSTR: Bad command lineCode: Select all
FOR /F "tokens=2 delims= " %%A in ('findstr /r /c:"EA ..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!GC O00" test.txt') do echo %%A
2)Dave said in his article that using the /G option is imprecise. Well I actually need to search for several GC variables in the file.
GC O00 GC K02 GC Q00 GC F05 GC C00
Could I make each of the search strings a variable so that I can shorten up the actual findstr command in the for loop. Do I have to escape the exclamations in the CR and LF variables so that they don't expand when setting them to a variable?
Code: Select all
:: Is this correct?
SET "S1=EA ..*^!CR^!*^!LF^!..*^!CR^!*^!LF^!..*^!CR^!*^!LF^!..*^!CR^!*^!LF^!GC O00"
:: Or is this OK?
SET "S2=EA ..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!GC K02"
SET "S3=EA ..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!GC Q00"
SET "S4=EA ..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!GC F05"
SET "S5=EA ..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!..*!CR!*!LF!GC C00"
FOR /F "tokens=2 delims= " %%A in ('findstr /r /c:"%S1%" /c:"%S2%" /c:"%S3%" /c:"%S4%" /c:"%S5%" test.txt') do echo %%A