如何使用终端使用单个命令运行多个脚本?(otoole)



例如,我想一次运行所有这些:

otool convert csv datafile data datafile.txtPython preprocess_data.py otoole dataffile .txt

所以我需要写一个脚本,我可以在终端调用,并将自动运行这两个命令。

我没有太多使用终端的经验,我刚刚开始阅读有关使用python执行shell命令的内容;操作系统。System、子进程、run等

我假定您正在bash终端中运行,如果是这样,您可以使用&&:

链接多个命令。
python some_file.py && python another_file.py && otoole blabla
或者,创建一个单独的文件some_filename.sh,并在其中,
#!/bin/bash
python some_file.py && python another_file.py && otoole blabla

然后你可以在终端中调用脚本:

./some_filename.sh

对于bash脚本,看一下这个