【发布时间】:2018-07-10 19:39:54
【问题描述】:
我正在尝试编写一个 bash 脚本,该脚本将从文件中读取变量对,然后在循环中使用它们。我正在尝试使用这个
while read p; do $p; echo "$a and $b"; done < text.txt
text.txt 包含以下内容:
a="teststring"; b="anothertest"
a="teststring1"; b="anothertest1"
a="teststring2"; b="anothertest2"
输出如下所示:
bash: a="teststring";: command not found
and
bash: a="teststring1";: command not found
and
我发现了类似的问题command line arguments from a file content
但无法弄清楚如何将答案应用于我的特定案例。谢谢!
【问题讨论】: