I've seen something along the lines of
if ! some-command; then #do something fi What's the effect of the exclamation point? I see that if you use brackets, it can be used for negation.
Is that the same effect here?
I've seen something along the lines of
if ! some-command; then #do something fi What's the effect of the exclamation point? I see that if you use brackets, it can be used for negation.
Is that the same effect here?
Correct.
Here is a code sample:
anny ~> if ! grep $USER /etc/passwd More input> then echo "your user account is not managed locally"; fi your user account is not managed locally anny > echo $? 0 anny > Source: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
echo $? will always return 0 because the exit status of the if...then...fi block is 0. Try it with different combination and you will see that it will always be 0 even when the if statement is broken, such as syntax errors.if...fi block is the exit status of the list within the block, not the exit status of the condition.