I’ve written bash scripts before, but I’m a little confused about how to do this with batch:
I have a program that outputs:
aaa boo
bbb boo
ccc boo
ddd boo
I’d like to iterate over the first column, and perform an action on each string.
How can I do this is batch?
var=OUTPUT
for col1 in var
echo col1
I can probably figure out the for loop part, but I don’t know how to get the column of output stored as a string.
EDIT: To clarify, I’m looking for a solution written in BATCH, for windows.
Thanks in advance for any help!
For MS batch on can use FOR /F
Process an output of a command:
or process contents of a variable:
http://www.robvanderwoude.com/ntfortokens.php