【发布时间】:2020-03-30 13:46:28
【问题描述】:
我可能有一些棘手的问题
如何在 bash 的 if 语句中调用定义的函数?
看看我的例子:
#!/bin/bash -x
Variable_A=xyz
function_x() {
echo "hello everyone"
}
#here I want to define a if statement after the function
if Variable_A == working;then
function_x()
#here I have a while for the parameters in bash example:
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--status)
Variable_A="$2"
shift
shift
;;
esac
done
所以我的想法是,当我运行脚本时,我们称它为 test.sh,它会在 bash 中运行脚本 exp:
./test.sh working
我不知道如何创建这样的东西,也许你们中的一些人可以帮助我。
提前谢谢你
【问题讨论】: