Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Notes on bash(1)



On Wed, Dec 09, 1998 at 11:19:27AM -0500, Jason Price wrote:
> >From zsh-workers:
> 
> (Quoting got screwed up... Sorry...)
> 
> Forwarded message:
> > > * ${parameter/pattern/string} and ${parameter//pattern/string}
> > >   pattern is expanded as per pathname expansion.  [munch]
> >
> > [munch]
> > Maybe it can be done quite simply by upgrading the extra flags Sven
> > added for # and % to match internal bits of a parameter's value.
> 
> there are a heck of a lot of ${...} modifiers that are wonderfully useful,
> but in my searching through the man pages, I havn't found an equivelent to
> basename /usr/local/bin/mumble -> mumble.  I need to pull the basename out
> of path strings quite offten, and I'd like to do so in shell.
> 
> Is this ... (wait, this is zsh) How can I do this?


~squid/logs foo=/usr/local/bin/mumble
~squid/logs echo $foo[(ws:/:)-1]      
mumble
~squid/logs foo=/usr/local/bin/mumble/
~squid/logs echo $foo[(ws:/:)-1]
mumble


This makes foo an array with the word separator `/' and gives the last
element in that array.

I am sure there are otherways to do this but this works for me.

Mike



Messages sorted by: Reverse Date, Date, Thread, Author