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
Bash else-if statement is used for multiple conditions. It is just like an addition to Bash if-else statement. In Bash elif, there can be several elif blocks with a boolean expression for each one of them. In the case of the first 'if statement', if a condition goes false, then the second 'if condition' is checked.
So as far as I can tell, %% doesn't have any special meaning in a bash function name. It would be just like using XX instead. This is despite the definition of a name in the manpage: name A word consisting only of alphanumeric characters and under- scores, and beginning with an alphabetic character or an under- score.
In short (in bash): Yes both = and == are the same (inside test constructs).
You can use variables as in any programming languages. There are no data types. A variable in bash can contain a number, a character, a string of characters. You have no need to declare a variable, just assigning a value to its reference will create it.
Absolutely.
$ echo "$foo"
$ echo "${foo=$(echo bar)}"
bar
$ echo "$foo"
bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With