开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜