[Gloucs] bash Q

Paul Broadhead lug at twinmoons.clara.co.uk
Sun May 13 17:34:59 BST 2007


Keith Edmunds wrote:

> On Sun, 13 May 2007 16:06:21 +0100
> Glyn Davies <glynd at walmore.com> wrote:
> 
> > In short, how can you obtain the part of the filename after the
> > last '.'?
> 
> lastpart=${filename##*.}

Interesting.  When faced with this sort of think I normally reverse the
string using rev, get the bit I need, then reverse it back again.

$ echo "dog.and.the.mouse" | rev | awk -F. '{print $1}' | rev
mouse

I don't know what the ##*. above is doing exactly but I hope to find
out....

Regards,
Paul




More information about the gloucs mailing list