Re: how to find the extension of a file?
From: Bill Seivert (seivert_at_pcisys.net)
Date: 02/28/05
- Next message: RichT: "Re: how to find the extension of a file?"
- Previous message: wmreinemer_at_tns.net: "Re: how to find the extension of a file?"
- In reply to: MDX: "how to find the extension of a file?"
- Next in thread: RichT: "Re: how to find the extension of a file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 27 Feb 2005 21:25:21 -0700
MDX wrote:
> Hi,
>
> I am trying to write a shell script which finds the extention of a file. I
> am doing it by manipulating the string. However, I hear the shell has tools
> that will output the extention of the file directly..
>
> Please advise
>
> Thanks in advance
> J
>
>
If you want just the very last extension, the following should work:
Given file=filename.ext,
extn=`expr "$file" : '.*\.\([^.][^.]*\)$'`
(untested)
Bill Seivert
- Next message: RichT: "Re: how to find the extension of a file?"
- Previous message: wmreinemer_at_tns.net: "Re: how to find the extension of a file?"
- In reply to: MDX: "how to find the extension of a file?"
- Next in thread: RichT: "Re: how to find the extension of a file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|