News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

FINDSTR command weird behaviour

Started by MazeGen, November 02, 2005, 04:11:23 PM

Previous topic - Next topic

MazeGen

I'm just fighting with batch scripts on my win xp.

Let's consider a tmp.txt file with the following contents:

Quotemasm32\ include

i.e. there is one line with two strings "masm32\" and "include", delimited with a space.

Let's say we want to find this line using FINDSTR command:

QuoteFINDSTR /C:"masm32\ include" tmp.txt

Too bad, FINDSTR cannot find the string! At first, I thought FINDSTR sees the backslash as a metacharacter, but when we try to change the strings to:

Quote
masm32\include
FINDSTR /C:"masm32\include" tmp.txt

it suddenly works, so the backslash is not seen as a metacharacter!

BTW, the /L option doesn't help here too.

Now I'm really confused. Any ideas, guys?

(you can find the FINDSTR description here)

arafel

you should use double backslash in the search request. i guess single \ followed by a space has some weird meaning to findstr while doing a literal search.
FINDSTR /C:"masm32\\ include" tmp.txt

MazeGen

Well, command line and batch scripts are very underdocumented, so it could be possible...

You're right that double backslash would be working, but the string is variable, not constant, and I never know what combinations have some special meaning. I already spent many hours writing a metacharacter parser (really horrible work!), but I can't get it working. When I almost finished it, I couldn't figure out some weird error... :( that's why I tried to revert to simple literal strings.

MazeGen

I totally forgot about old MS-DOS FIND. It doesn't allow regural expressions, so works better than its extended version, FINDSTR.
I only wonder why FIND has that weird output :(

Quote

---------- TMP.TXT
masm32\ include