且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在终端中运行文本文件

更新时间:1970-01-01 07:58:42

这称为"shell脚本".

That's called a "shell script."

将此添加到文件顶部:

#!/bin/sh

然后执行以下命令:

chmod +x filename

然后像执行程序一样执行它:

Then execute it like a program:

./filename

或者,您可以直接执行Shell,告诉它执行文件中的命令:

Alternately, you can execute the shell directly, telling it to execute the commands in your file:

sh -e filename