且构网

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

如何在不使用“sh"的情况下运行 shell 脚本?或“bash"命令?

更新时间:2022-11-03 13:41:39

在文件顶部添加shebang":

Add a "shebang" at the top of your file:

#!/bin/bash

并使您的文件可执行(chmod +x script.sh).

And make your file executable (chmod +x script.sh).

最后修改你的路径,添加你的脚本所在的目录:

Finally, modify your path to add the directory where your script is located:

export PATH=$PATH:/appropriate/directory

(通常,您希望 $HOME/bin 用于存储您自己的脚本)

(typically, you want $HOME/bin for storing your own scripts)