Results 1 to 3 of 3
I have a script:
Code:
#!/bin/bash
THEYEAR=2011
LASTYEAR=$(($THEYEAR - 1))
echo $THEYEAR
echo $LASTYEAR
I get:
2011
2010
I have another script:
Code:
#!/bin/bash
THEYEAR=TZ=EST-24 date +20%y
LASTYEAR=$(($THEYEAR - 1))
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-24-2011 #1Just Joined!
- Join Date
- Apr 2005
- Posts
- 37
[SOLVED] Subtracting years from current year
I have a script:
I get:Code:#!/bin/bash THEYEAR=2011 LASTYEAR=$(($THEYEAR - 1)) echo $THEYEAR echo $LASTYEAR
2011
2010
I have another script:
I get:Code:#!/bin/bash THEYEAR=TZ=EST-24 date +20%y LASTYEAR=$(($THEYEAR - 1)) echo $THEYEAR echo $LASTYEAR
2011
-1
THEYEAR is correct but then I get a line space and then a -1 for LASTYEAR.
I can't figure out why.
- 02-24-2011 #2
try this
#!/bin/bash
THEYEAR=`TZ=EST-24 date +20%y`
echo "$THEYEAR the year";
LASTYEAR=$((`echo $THEYEAR`-1))
echo $THEYEAR
echo $LASTYEAR
- 02-25-2011 #3Just Joined!
- Join Date
- Apr 2005
- Posts
- 37




