-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Greg Wooledge on 11/4/2009 6:23 AM: > On the other hand, removing a single leading zero is not difficult: > > month=$(date +%m) month=${month#0} # Removing leading 0
Not portable. Assigning the same variable twice in the same statement has different order of operations in some shells. Use: month=$(date +%m); month=${month#0} instead. > next_month=$(( ($month == 12) ? 1 : $month+1 )) > > Removing multiple leading zeroes, however, requires either a loop, or the > use of extended globs. Not true. You can do it via POSIX and without a loop by using an intermediate variable: foo=00081 bar=${foo%%[!0]*} foo=${foo#$bar}} - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrxgn0ACgkQ84KuGfSFAYDyCACg0suH5IFGv+4dOe5Bf3kyBExR R20AoM+U/AP6tqrF0QpEEYWgvjfx2m+H =aC1b -----END PGP SIGNATURE-----