On Tue, 1 Feb 2000, Greg Olszewski wrote:

> On Mon, Jan 31, 2000 at 07:48:38PM +0200, Ralf Christian Strandell wrote:
> > Hello!
> > 
> > How do I remove the last character of a string
> > stored in an environmental variable?
> > 
> > ie. if $VAR=abcd then how do I get $VAR=abc ?
> > 
> > ----------
> > I need this to keep track of position in
> > a menu tree.
> > 
> > Ralf
> 
> VAR=${VAR:0:${#VAR}-1}
> works in bash 2.03.0(1)
> this is shell specific however. You should check out the man page
> for whatever shell you are using, that's where I figured this out.
> 
If you really need not to be shell specific, you could do something like:
VAR=`echo $VAR | sed 's/^\(.*\).$/\1/'`

-- 
Mike Ricketts <[EMAIL PROTECTED]>

I would like to urinate in an OVULAR, porcelain pool --


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to