我有2个shell脚本.
第二个shell脚本包含以下函数 second.sh
func1
func2
Run Code Online (Sandbox Code Playgroud)
first.sh将使用一些参数调用第二个shell脚本,并将使用特定于该函数的其他一些参数调用func1和func2.
以下是我所谈论的例子
second.sh
val1=`echo $1`
val2=`echo $2`
function func1 {
fun=`echo $1`
book=`echo $2`
}
function func2 {
fun2=`echo $1`
book2=`echo $2`
}
Run Code Online (Sandbox Code Playgroud)
first.sh
second.sh cricket football
func1 love horror
func2 ball mystery
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现它?
我试图编写一个使用if
语句的Bash脚本.
if [$CHOICE -eq 1];
Run Code Online (Sandbox Code Playgroud)
剧本是给我的错误,直到我后得到的空间[
和之前]
如下所示:
if [ $CHOICE -eq 1 ];
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么方括号周围的空间在Bash中如此重要?
如何在Windows中使用命令行运行的批处理文件中生成GUID?
我正在尝试自动化我们的应用程序备份.过程的一部分是检查的退出状态egrep
中的if
语句:
if [ ! -f /opt/apps/SiteScope_backup/sitescope_configuration.zip ] ||
[ egrep -i -q "error|warning|fatal|missing|critical" "$File" ]
then
echo "testing"
fi
Run Code Online (Sandbox Code Playgroud)
我希望它输出,testing
因为文件存在并egrep
返回成功,但我得到一个错误:
-bash: [: too many arguments
Run Code Online (Sandbox Code Playgroud)
我尝试了各种语法 - 附加括号,引号等但错误仍然存在.
请帮助我理解我哪里出错了.
bash ×2
if-statement ×2
batch-file ×1
cmd ×1
command-line ×1
guid ×1
shell ×1
syntax ×1
unix ×1