提问人:john Wallace 提问时间:11/15/2023 更新时间:11/15/2023 访问量:8
循环外部文件,将每一行作为可变命令添加到命令中
Cycling an external file adding each line into a command as a varable
问:
我尝试使用一个包含多行的外部文件,将每一行用作变量,并在 bash 中完成一个简单的命令并保存到多个外部文件中。
例如,我的文件命令 .txt 有:
Group1=“足球” Group2=“板球” Group3=“壁球”
我想运行以下命令:
grep 'group-title=“$Group 1' -B 1 'commands.txt' > Football.txt grep 'group-title=”$Group 2' -B 1 'commands.txt' > Cricket.txt
grep 'group-title=“$Group 3' -B 1 'commands.txt' > Squash.txt
我假设我可以使用 for 循环来确保所有行都被使用和执行,但我无法弄清楚如何使用变量本身并循环遍历每一行。
John。
答: 暂无答案
评论