sj1*_*j17 2 shell bash shell-script
a=Y
b=Y
c=Y
if condition like $a=='y' then execute all this statements******
cat *.tar.gz | tar -xzvf - -i
echo "5"
tar -xvf *.tar.gz
echo "9"
rm -rf *.tar.gz
elif($b=='y') condition ***
cp $source $destination
cp $source/conf/* $destination/conf
else (**** )
some commands
Run Code Online (Sandbox Code Playgroud)
-if语句的标准形式是
if condition; then
action
action
...
elif condition; then
action
action
...
else
action
action
...
fi
Run Code Online (Sandbox Code Playgroud)
其中elif和else分支是可选的,并且可能有多个elif分支。
在你的情况下:
if [ "$a" = "y" ]; then
cat *.tar.gz | tar -xzvf - -i
echo "5"
tar -xvf *.tar.gz
echo "9"
rm -rf *.tar.gz
elif [ "$b" = "y" ]; then
cp "$source" "$destination"
cp "$source"/conf/* "$destination"/conf
else
some commands
fi
Run Code Online (Sandbox Code Playgroud)
我没有在这里查看您想要执行的实际命令,以及它们是否有意义。
| 归档时间: |
|
| 查看次数: |
19720 次 |
| 最近记录: |