I can think of a few ways to do this - but they are all long winded & can no doubt be improved on.
I need to set an environment variable to the number of the month before last. What I mean is that when I run my script in March I want $MONTH=01, in January $MONTH=11.
- date +%m gives me '03' for month,
- I can use expr to subtract 2, but this gives me '1' not '01' (& won't work in Jan or Feb anyway so I'd have to do something fancy for these months)
- I could use sed to prefix a '0' where required
As usual I'd be interested to hear what the experts suggest!
The usual thanks in advance ... Chris
I need to set an environment variable to the number of the month before last. What I mean is that when I run my script in March I want $MONTH=01, in January $MONTH=11.
- date +%m gives me '03' for month,
- I can use expr to subtract 2, but this gives me '1' not '01' (& won't work in Jan or Feb anyway so I'd have to do something fancy for these months)
- I could use sed to prefix a '0' where required
As usual I'd be interested to hear what the experts suggest!
The usual thanks in advance ... Chris