Bash if statement: Can I assign and compare?

I want to do something like:

if [ CURRENT=$(stat -c %Y $STATUS_FILE) -ne $LASTUPDATE ]
    then LASTUPDATE = $CURRENT
fi

That is ... I want to assign a variable and perform a comparison, since I will use this variable later

+5
source share
1 answer

That's right.

$ echo "$foo"

$ echo "${foo=$(echo bar)}"
bar
$ echo "$foo"
bar
+5
source

All Articles