On Fri, Jul 30, 2021 at 08:48:28AM +0300, Teemu Likonen wrote: > scanimage > /home/mick/DATA/SCANS/scan-$((++ct)).pnm
Correct, but not necessarily an improvement over the original code. It depends on your taste for complexity. > You have already got answers but here is another. Bash has a special > arithmetic evaluation mode which happens in: > > let ... # returns true (0) or false (1) > (( ... )) # returns true (0) or false (1) > $(( ... )) # returns the value of the expression The word "returns" is a bit misleading in the last case. It doesn't set the exit status (as seen in the $? special parameter) to the value of the expression the way the first two set it to 0 or 1. The last one is a substitution, meaning it's *replaced* inline by the value of the expression. echo $((4 + 2)) # equivalent to echo 6 x=$((x + 1)) # POSIX version of ((x++)) or let x++ echo "The size is $size ($((size/(1024*1024))) MB)"

