linux - 如何以最少的击键启动 Bash 脚本

标签 linux bash shell unix

要从命令行启动 shell 脚本,而不是在 Linux/Unix 命令行中键入:

~$ <shell> tale.sh

在我的例子中,使用 bash:

 ~$ bash tale.sh

如何设置 profile/defaults/scripts 以便命令仅运行:

~$ tale

我知道这对于不同的 shell 可能是不同的。我需要 bash 的答案。

这是 ~/tale.sh 的完整 list :

#! /bin/bash
tail -f ~/lp/_logs/error.log

那个文件,~/lp/_logs/error.log,是一个 PHP 错误日志。

最佳答案

首先,您需要重命名您的脚本:

mv tale.sh tale

然后,可能还有两个额外的步骤:

1) 在脚本上设置可执行位:

chmod +x tale

2) 确保您的脚本在您的 PATH 中。例如,您可以将它放在您的 bin 目录中(假设您的 bin 目录在您的路径中):

mv tale ~/bin

一旦所有这些准备就绪,无论您使用哪个 shell,您的脚本都可以从任何地方运行。

关于linux - 如何以最少的击键启动 Bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30971611/

相关文章:

linux - objdump 如何发出 intel 语法

linux - 我想将一个脚本的输出通过管道传输到将独立处理第一个脚本的输出的不同脚本?

bash - 如何将数字拆分为字符数组

bash - 或者 Solaris 中 Shell 脚本中的条件

C++ Boost ASIO 简单的周期性定时器?

linux - shell脚本的意外行为

BASH:OSX 中的 $(date) 结果为 "Illegal variable name"

linux - 在linux内核中执行bash脚本

macos - gfortran : fatal error: no input files compilation terminated

Python stdout 重定向(特殊)