我如何在不使用&QUOT运行一个shell脚本; SH"或QUOT;庆典"命令?

我如何在不使用&QUOT运行一个shell脚本; SH"或QUOT;庆典"命令?

问题描述:

我有我要在不使用的嘘或打击的命令运行shell脚本。例如:

I have a shell script which I want to run without using the "sh" or "bash" commands. For example:

而不是: SH script.sh

我要使用: script.sh

我怎样才能做到这一点?

How can I do this?

P.S。 (一)我没有太多使用shell脚本,我试图阅读有关别名,但我不知道如何使用它们。

P.S. (i) I don't use shell script much and I tried reading about aliases, but I did not understand how to use them.

(二)我也看了关于与在PATH变量另一个文件链接的脚本。我用我的学校服务器,我没有权限创建在这些地点的文件。

(ii) I also read about linking the script with another file in the PATH variables. I am using my university server and I don't have permissions to create a file in those locations.

在你的文件的顶部添加一个认领:

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中用于存储自己的脚本)