1

Given a text file file.txt containing

XXX-YYY-ZZZZ some other text
AAA-BBB-CCCC more text
UUU-VVV-WWWW etc etc

and a Windows .bat file

I'm seeking for a solution such that the string from each beginning of the line up to the first blank (excluding) will be extracted from the file and be given an executable in the .bat file as an argument.

The UNIX sh/sed pendant to which the following would be:

 for i in `cat file.txt | sed 's/ .*$//' `; do echo $i; done

with "echo" standing as a placeholder for the executable I would like to pass the argument to.

1 Answer 1

1
for /f "usebackq tokens=1 delims= " %%a in ("file_path.txt") do echo %%a

?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That's exactly what I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.