[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Extract the last n characters from a variable
From: |
Chet Ramey |
Subject: |
Re: Extract the last n characters from a variable |
Date: |
Thu, 21 Dec 2000 10:10:31 -0500 |
> Configuration Information [Automatically generated, do not change]:
> Machine: i586
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-mandrake-linux-gnu'
> -DCONF_VENDOR='mandrake' -DSHELL -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -I.
> -I/usr/include -I. -I./lib -I/usr/include -O3 -fomit-frame-pointer
> -fno-exceptions -fno-rtti -pipe -s -mpentium -mcpu=pentium -march=pentium
> -ffast-math -fexpensive-optimizations
> uname output: Linux bernard.vaissiere-favre.com 2.2.16 #4 mar aoĆ» 22 09:40:00
> CEST 2000 i686 unknown
> Machine Type: i586-mandrake-linux-gnu
>
> Bash Version: 2.03
> Patch Level: 19
> Release Status: release
>
> Description:
> I need to extract de last 2 characters from a variable.
> So, I try the syntax : ${varname:-2}. I think that there's a
> confusion with ${varname:-default_value}. Examples :
Just insert a space:
${varname: -2}
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/