Re: extract chars after a last dot

From: stephan beal (stephan_at_wanderinghorse.net)
Date: 08/04/03


Date: Mon, 04 Aug 2003 16:26:34 +0200

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"

If you use bash, you can do this:

stephan@cheyenne:~/> export foo=one.two.three
stephan@cheyenne:~/> echo ${foo##*.}
three

loop over a set of files with:
for i in *.*; do ext=${i##*.}; echo $ext; done

-- 
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may 
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.


Relevant Pages

  • Re: extract chars after a last dot
    ... On Mon, 04 Aug 2003 at 11:22 GMT, mike wrote: ... > how do i extract the characters after the last dot? ...
    (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: 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)
  • Re: HTML - Extract Specific Text
    ... etc.) that can be used in any calculation. ... imported text is standardised you can easily extract whatever you want. ... a VBA script. ... and then takes the 11 characters starting with the fourth ...
    (comp.databases.filemaker)

Loading