[英]Substituting lines of a text file into bash commands
我想为文本文件的每一行运行一次bash命令。
如果我做:
while read l; do
echo $l;
done < myfile.txt
我得到每一行的回声。
但是当我使用实际命令时:
while read l; do
curl -X POST http://somedomain -H "Content-Type: application/json" -d $l
done < myfile.txt
我得到错误。 我认为这可能与转义文本文件中的字符有关,但是我没有尝试过。 为文本文件的每一行运行一次curl表达式的正确方法是什么?
使用引号。
foocmd ... "$l"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.