command to strip suffix in .sh script

George Davidovich freebsd at optimis.net
Thu Jun 3 17:00:33 UTC 2010


On Thu, Jun 03, 2010 at 11:11:16PM +0700, Anh Ky Huynh wrote:
> On Wed, 02 Jun 2010 20:25:36 -0400 Vinny wrote:
> > On 06/02/2010 04:30, Matthew Seaman wrote:
> > > On 02/06/2010 09:24:01, Matthias Apitz wrote:
> > > > Aiza wrote:
> > > >
> > > > > I have this code
> > [snip]
> > > > $ echo 'archivename-201006021514.34.tar.gz' | sed 's/-.*$//'
> > >
> > > archive_name=${fromarchive%-*}
> >  
> > Thanks Matthew, that's really neat.  It took me a long time to find
> > the correct google incantation to find the documentation for that.
> > ( bourne shell pattern-matching notation )
> 
> In fact I know about that from Bash's documents:) IMHO, there are more
> Bash's documents than Bourne's ones.

Kids today. ;-)  

No need for Magick Google Incantations:

  man sh   | less -p 'Parameter Expansion$'
  man bash | less -p 'Parameter Expansion$'

-- 
George


More information about the freebsd-questions mailing list