[TriLUG] BASH oddity
Paul G. Szabady
Paul at ThyService.com
Tue Feb 21 17:29:17 EST 2006
Greetings,
I'm trying to write a script and find something confusing. If you look at
the examples below, I was using #2. It works if I manually set it to '8',
but not '08'. It works with both '6' and '06'.
So, what's special about '08'?
#1
[paul at at paul]$ declare -i dirx=$(date +%g)
[paul at at paul]$ echo $dirx
6
#2
[paul at at paul]$ declare -i dirx=$(date +%V)
-bash: declare: 08: value too great for base (error token is "08")
[paul at at paul]$ echo $dirx
6
#3
[paul at at paul]$ declare -i dirx=08
-bash: declare: 08: value too great for base (error token is "08")
[paul at at paul]$ echo $dirx
6
#4
[paul at at paul]$ declare -i dirx=8
[paul at at paul]$ echo $dirx
8
#5
[paul at at paul]$ declare -i dirx=06
[paul at at paul]$ echo $dirx
6
[paul at at paul]$ export thisweek=(date +%g) ; echo $thisweek
(date +%g)
[paul at at paul]$ export thisweek=$(date +%g) ; echo $thisweek
06
[paul at at paul]$ export thisweek=$(date +%V) ; echo $thisweek
08
[paul at at paul]$
--
Paul
@ Thy Service
More information about the TriLUG
mailing list