| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
| List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT sources DOT redhat DOT com |
| Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
| Message-Id: | <5.1.0.14.2.20010626123753.025b18d0@pop3.cris.com> |
| X-Sender: | rrschulz AT pop3 DOT cris DOT com |
| X-Mailer: | QUALCOMM Windows Eudora Version 5.1 |
| Date: | Tue, 26 Jun 2001 12:43:46 -0700 |
| To: | Glen Coakley <gcoakley AT mqsoftware DOT com>, cygwin AT cygwin DOT com |
| From: | Randall R Schulz <rrschulz AT cris DOT com> |
| Subject: | RE: How to extract suffix from a filename? |
| In-Reply-To: | <E1B42CFD544FD31193EE0000E87C5CE7E07EE1@mailserver2.mqsoftw |
| are.com> | |
| Mime-Version: | 1.0 |
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |