This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to extract suffix from a filename?


Glen,

That's a lot of overhead for what could be done entirely within a single shell:

On top of the shell that's interpreting these command lines, there is:

1 fork/exec for the sub-shell interpreting the backquote expression
1 fork/exec for basename
1 fork/exec for sed
1 pipe creation

Personally, I much prefer the shell-only approach I explained.

Randall Schulz
Mountain View, CA USA


At 12:02 2001-06-26, Glen Coakley wrote:

>This breaks on extensions that are not three characters, such as ".html".
>(Note: This includes the period.) The following will work for any length
>extension.
>
>     ext=`basename $filepath | sed -e 's/\(.*\\.).*/\1/g'`
>
>If you don't want the period:
>
>     ext=`basename $filepath | sed -e 's/\(.*\)\..*/\1/g'`
>
>________________________________
>Glen Coakley


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]