# no need for expr to increment $NEWNUM NEWNUM=$(( ${CURNUM} + 1))
If CURNUM is empty, or not a number, NEWNUM will be assigned a value of "1"
This whole messy code I came up with was due to bash not liking leading zeros for calculations. If my input of $CURNUM is "001" it will calculate it as "2" instead of "002".
NUMLEN=`expr length $NEWNUM`
No need for that line, unless you actually need $NUMLEN at some other point. If you do, you don't need to use expr:
# return the length of the variable $NEWNUM NUMLEN=${#NEWNUM}
Thanks, expr was first thing to come on my mind to do that. I need NUMLEN so I can know how many zeros to add to file identifier.
And these can be reduced to one line:
FID=$(printf "%03u" "${NEW_NUM}")
Thanks! I was missing that, seems to have done the trick replacing my checks, but something funky is going on there with numbers like 010 or anything starting with one zero: root@sgd1 [~/bin]# NEWNUM="015" root@sgd1 [~/bin]# echo $NEWNUM 015 root@sgd1 [~/bin]# printf "%03u" "${NEWNUM}" 013 Any ideas ? -- Best regards, Nick Zeljkovic -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org