Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String Windows批处理文件,用于迭代从文本文件提取的字符串_String_Windows_Loops_Batch File - Fatal编程技术网

String Windows批处理文件,用于迭代从文本文件提取的字符串

String Windows批处理文件,用于迭代从文本文件提取的字符串,string,windows,loops,batch-file,String,Windows,Loops,Batch File,给定一个文本文件file.txt,其中包含 XXX-YYY-ZZZZ some other text AAA-BBB-CCCC more text UUU-VVV-WWWW etc etc 和一个Windows.bat文件 我正在寻找一种解决方案,从行的每个开头到第一个空格(排除)的字符串都将从文件中提取出来,并在.bat文件中作为参数提供一个可执行文件 UNIX sh/sed挂件,其中将包含以下内容: for i in `cat file.txt | sed 's/ .*$//' `; d

给定一个文本文件file.txt,其中包含

XXX-YYY-ZZZZ some other text
AAA-BBB-CCCC more text
UUU-VVV-WWWW etc etc
和一个Windows.bat文件

我正在寻找一种解决方案,从行的每个开头到第一个空格(排除)的字符串都将从文件中提取出来,并在.bat文件中作为参数提供一个可执行文件

UNIX sh/sed挂件,其中将包含以下内容:

 for i in `cat file.txt | sed 's/ .*$//' `; do echo $i; done
“echo”作为可执行文件的占位符,我想把参数传递给它

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

谢谢。这正是我想要的。