How to build a conditional assignment in bash?

后端 未结 8 2037
慢半拍i
慢半拍i 2021-01-31 01:04

I\'m looking a way to build conditional assignments in bash:

In Java it looks like this:

int variable= (condition) ? 1 : 0;
8条回答
  •  情话喂你
    2021-01-31 01:59

    I wanted to do a conditional assignment with strings and I ended up with :

    SOWHAT=$([ "$MYVALUE" = "value" ] && echo "YES" || echo "NO")
    

提交回复
热议问题