我如何在不使用&QUOT运行一个shell脚本; SH"或QUOT;庆典"命令? [英] How do I run a shell script without using "sh" or "bash" commands?

查看:126
本文介绍了我如何在不使用&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中用于存储自己的脚本)

这篇关于我如何在不使用&QUOT运行一个shell脚本; SH"或QUOT;庆典"命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆