> > 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 ?
> >
> VAR=${VAR:0:${#VAR}-1}
> works in bash 2.03.0(1)

Thanks, that works in ksh also.

I forgot to say that I need a solution 
that uses sh only. Sorry.

I got an additional hint and solved the problem using expr:

        LEN=`expr length $VAR`             # store length of $VAR in
$LEN
        LEN=`expr $LEN - 1`                # decrement $LEN by 1
        VAR=`expr substr $VAR 1 $LEN`      # change $VAR to substring of
$VAR

Ralf Strandell

-
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