On Tue, 22 Aug 2000, CaT wrote:
> On Tue, Aug 22, 2000 at 12:49:08PM +1000, John Ferlito wrote:
> > On Tue, Aug 22, 2000 at 12:36:51PM +1000, Doug Stalker wrote:
> > > 
> > > I'm sure this is easy but U'm having a big mental blank when I try to do
> > > it.
> > > 
> > > I have a variable in a shell script (#!/bin/sh) which is a number
> > > representing a month.  It has a 0 in the front if it is less than ten
> > > (ie: July is 07) but I need to remove that leading zero.  How can I do
> > > this?
> > 
> > newmonth = `echo $oldmonth | sed -e 's/0\([1-9]\)/\1/'`
> 
> Hmmm...
> 
> newmonth = `echo $oldmonth | sed -e 's/^0//'`

or how about using  Arithmetic Expansion:

% oldmonth='07'
% echo $oldmonth
07
% echo $((oldmonth))
7


--
Jim.





--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to