开发者

Bash if statement: Can I do an assignment and comparison?

开发者 https://www.devze.com 2023-03-18 10:52 出处:网络
I want to do something like: if [ CURRENT=$(stat -c %Y $STATUS_FILE) -ne $LASTUPDATE ] then LASTUPDATE = $CURRENT

I want to do something like:

if [ CURRENT=$(stat -c %Y $STATUS_FILE) -ne $LASTUPDATE ]
    then LASTUPDATE = $CURRENT
fi
开发者_如何学JAVA

That is... I want to assign a variable and do a comparison since I'll use that variable later


Absolutely.

$ echo "$foo"

$ echo "${foo=$(echo bar)}"
bar
$ echo "$foo"
bar
0

精彩评论

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