When writing bash shell scripts, I keep forgetting how to do arithmetric.... so here is a reminder for me ....
#!/bin/bash # Either : f=10 let f=f+1 echo "$f is now 11" # Or : f=10 f=$(($f+1)) echo "$f is now 11" # More advanced : # (Random number between 0 and 8 inclusive) f=`perl -le 'print int rand 9'` echo "$(($f+10)), $(($f+20)), $(($f+30)) prints e.g. 2, 14, 24, 24"
End memory jogging post.
Comments
Post new comment