如何获取其中的目录路径的Bash脚本位于,里面那个脚本?
例如,假设我想使用Bash脚本作为另一个应用程序的启动器.我想将工作目录更改为Bash脚本所在的目录,因此我可以对该目录中的文件进行操作,如下所示:
$ ./application
我有两个shell脚本,a.sh和b.sh.
如何b.sh从shell脚本中调用a.sh?
我有一个使用shshell 的脚本.我在使用该source命令的行中出错.它似乎source没有包含在我的shshell中.
如果我明确尝试source从shell 运行我得到:
sh: 1: source: not found
Run Code Online (Sandbox Code Playgroud)
我应该以某种方式安装"源"?我的版本有错sh吗?
在我的.bashrc中,我有一个名为hello的函数:
function hello() {
echo "Hello, $1!"
}
Run Code Online (Sandbox Code Playgroud)
我希望能够从shell调用hello(),如下所示:
$ hello Lloyd
Run Code Online (Sandbox Code Playgroud)
得到输出:
> Hello, Lloyd!
Run Code Online (Sandbox Code Playgroud)
有什么诀窍?
(当然,我想到的真正功能更复杂.)
编辑:这真的是由函数中的语法错误引起的,我想!:(
function coolness() {
if[ [-z "$1"] -o [-z "$2"] ]; then
echo "Usage: $0 [sub_package] [endpoint]";
exit 1;
fi
echo "Hi!"
}
Run Code Online (Sandbox Code Playgroud) cat global_features_script.sh
.child1_script.sh
.child2_script.sh
function svn_credentials
{
echo -n "Enter the svn username and press [ENTER]: " > /dev/tty
read svn_username
echo -n "Enter the svn commit message and press [ENTER]: " > /dev/tty
read svn_message
echo -n "Enter your svn password and press [ENTER]: " > /dev/tty
read -s svn_password
}
if [ a == b]
then
echo "a is equal to be b"
else
echo "a is not equal to b"
fi
function exit_error
{
echo " There …Run Code Online (Sandbox Code Playgroud)