Re: Bash Adding 09 or 9.1 etc
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Sat, 28 Oct 2006 05:26:51 -0400
On 2006-10-28, Keith wrote:
I have a script that gives a error in BASH whenever I try to add 01-09
with 1.
X="09"
X=$((X+1))
line 42: 09: value too great for base (error token is "09")
This is caused by a date command variable and I'm trying to avoid
having to make other changes in the script.
Numbers beginning with 0 are taken as octal. With date number it is
easy to remove leading digits:
X=09
X=$(( ${X#0} + 1 ))
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- References:
- Bash Adding 09 or 9.1 etc
- From: Keith
- Bash Adding 09 or 9.1 etc
- Prev by Date: cut
- Next by Date: Re: return values from a function call
- Previous by thread: Bash Adding 09 or 9.1 etc
- Next by thread: Re: Bash Adding 09 or 9.1 etc
- Index(es):
Relevant Pages
|