8

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 do a comparison since I'll use that variable later

1

1 Answer 1

10

Absolutely.

$ echo "$foo" $ echo "${foo=$(echo bar)}" bar $ echo "$foo" bar 
Sign up to request clarification or add additional context in comments.

4 Comments

I think you completely missed the point of his question. I think he wants to do an assignment inside of an IF statement.
Thank you, I had been playing with that but omitted the quotes, not realizing my mistake.
Nope, he got it, I was able to plop this right down in an IF statement successfully, example: if [ "${VAR=$(echo 1)}" -eq 1 ]; echo $VAR; yields "1"
Okay, my bad then. I'd remove my down vote, but I waited too long... if you edit your answer, I can remove it... :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.