![](/img/trans.png)
[英]Read a file line by line -> search for each line in another text document, if match, output to another text file
[英]how to read a file line by line and each line as an argument input to a .exe file and capture the output to another file in linux
我尝试编写一个 shell 脚本逐行读取 a.txt 文件,每一行都将作为 my.exe 文件的输入,我还想捕获.exe 文件的 output 并将其导出到另一个.txt 文件. 我的代码喜欢这样,但它不起作用。 当我尝试像“./caculate.exe“1”这样手动输入时,程序也不将1作为输入,仍然要求我再次手动输入。
#!/bin/bash
while IFS= read -r LINE; do
./caculate.exe "$LINE"
done < data.txt > f.txt
如果calculate.exe
通常从标准输入中获取输入,则需要将变量pipe给它,而不是使用参数。
#!/bin/bash
while IFS= read -r LINE
do
printf "%s\n" "$line" | ./calculate.exe
done < data.txt > f.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.