终端(OS X),来自文件的命令队列

Sti*_*ery 5 macos terminal command

我想在Mac终端中执行命令队列.是否可以准备包含一系列命令的文件,并通过终端提交文件?例如... commands.txt包含几个命令,每行一个:

./executable_file -f sub_a 100
./executable_file -f sub_b 100
./executable_file -f sub_c 100
./executable_file -f sub_d 100
...
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

And*_*ehm 8

也许我误解了你,但这听起来像是一个shell脚本文件的典型案例.

创建一个文件"myscript.sh",将命令添加到其中.做第一行

#!/bin/sh
Run Code Online (Sandbox Code Playgroud)

告诉OS X如何处理该文件.然后将其标记为可执行文件(chmod + x myscript.sh)并按./myscript.sh运行它.

这应该够了吧.