Hey guys,

Hope I'm not posting into the wrong section. I think I have something very simple that i'm having a lot of trouble with. I have a text file called "file.txt"

It contains:
TagString=V3,SCC-COM,WXF1A20V0556,WXE1A2071007,PREBI
TagString=V3,SCC-COM,WXK1A1045668,WXG1A30F3909,POSTBI
TagString=V3,SCC-COM,WMAYP0002467,WMAYP0002769,BI

I want to run a batch file that'll parse the 1st & 2nd token.

So:

for /f "tokens=3,4,5 delims=," %i in (file.txt) do @echo %i %j %k

why won't this work?

Thanks.


What language is that? It doesn't look like a shell script.

In a shell script, parse the file like this:

while IFS== read -r var val
do
   IFS=,
   set -f
   set -- $val
   set +f

   echo "$# tokens"

   token1=$1
   token2=$2
   tokenN=$N
   : etc....
done < file.txt

Looks to me as if poor Grep is stuck in a Microsoft environment. Clue one: he uses 'batch' instead of 'script'. Clue two: "@echo" ... I seem to recall something about a leading '@' in dos batch files. Alas, I no longer remember enough about such things to be helpful.

Looks to me as if poor Grep is stuck in a Microsoft environment. Clue one: he uses 'batch' instead of 'script'. Clue two: "@echo" ... I seem to recall something about a leading '@' in dos batch files. Alas, I no longer remember enough about such things to be helpful.

Yes, after reading the first response i was like ah crap, posted in the wrong section =/
I got it figured out though. Thanks.

This question has already been answered. Start a new discussion instead.