开发者

Multiple statements in if else statement in shell scripting

开发者 https://www.devze.com 2023-02-12 18:54 出处:网络
I want to ask is it possible to give multiple statements to开发者_如何转开发 be executed when if condition gets satisfied by doing just

I want to ask is it possible to give multiple statements to开发者_如何转开发 be executed when if condition gets satisfied by doing just

if[condition] then
statements
else
statements
fi

or we have to do something else like using do.....done around that block of statements


Yes you can have multiple statements:

if [ condition ]; then
  echo 'foo'
  echo 'bar'
else
  echo 'hello'
  echo 'world'
fi
0

精彩评论

暂无评论...
验证码 换一张
取 消