[Gllug] Arithmetic error in bash on 08 and 09?
Tethys
tet at createservices.com
Thu Jul 22 15:34:49 UTC 2004
"C. Cooke" writes:
># Turn on extended globbing ( off by default in bash! )
>shopt -s extglob
>
># Get the number
>num="$(date +%U)"
>
># Strip off leading 0s (uses extended globbing)
>clean="${num##+(0)}"
No need for extended globbing. You can do it without:
clean="${num//#0/}"
But you don't actually need to remove the leading zero anyway. Just tell
the shell it's in base10:
num=$((10#$(date +%U) + 1))
file="$(printf XXX%02d.log $num)"
Tet
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list