Re: extract chars after a last dot

From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 08/04/03


Date: 4 Aug 2003 21:54:21 GMT

On Mon, 04 Aug 2003 at 11:22 GMT, mike wrote:
> hi
>
> i have files with names test.1 and test.file.10
> how do i extract the characters after the last dot? so in the example
> it would be
>
> 1) test.1 extract to "1"
> 2) test.file.10 extract to "10"

var=test.file.10

    In a POSIX shell, such as sh (on *BSD), bash, ksh, etc.:

echo ${var##*.}

    In any shell:

expr "x$var" : '.*\.\(.*\)'

-- 
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: extract chars after a last dot
    ... > how do i extract the characters after the last dot? ... If you use bash, you can do this: ...
    (comp.unix.shell)
  • RE: Can I use an "If, then" function here...
    ... If the number of numerics after the dot is not fixed; ... you can use this..which will extract the ... characters after the first dot. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: extract chars after a last dot
    ... mike wrote: ... > how do i extract the characters after the last dot? ...
    (comp.unix.shell)
  • Re: How many years dedicated to characters learning in China ?
    ... the characters used are obvious. ... Mike> I don't think that's what his question is about. ... Mike> My point is that written Chinese compounds are at least as ... Mike> pronounce the characters involved, ...
    (sci.lang)
  • Re: Using periods/dots within file names
    ... My partner and I have used and successfully tested what I created and refer to as the Dot Notation File Naming Schema. ... Have fun with your "descriptive" naming noting the only legitimate and required limits are those imposed by the file system which limits the total number of alphanumeric characters in the string used to name a file noting the. ... As I recall even the 8.3 file naming convention allowed us to delineate file names using any number of dots noting we only had 8 characters to work with for the name so doing so was not as practical as we can now take advantage of on the Windows file system which support 256 characters in a file name. ...
    (microsoft.public.dotnet.general)

Quantcast