From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4048 invoked from network); 9 Dec 1998 16:45:51 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Dec 1998 16:45:51 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id LAA26376; Wed, 9 Dec 1998 11:40:04 -0500 (EST) Resent-Date: Wed, 9 Dec 1998 11:39:58 -0500 (EST) From: "Michael Barnes" Message-ID: <19981209113859.A21246@mibarnes.lib.vt.edu> Date: Wed, 9 Dec 1998 11:38:59 -0500 To: zsh-users@math.gatech.edu Subject: Re: Notes on bash(1) Mail-Followup-To: zsh-users@math.gatech.edu References: <199812091619.LAA15213@gypsy.cad.gatech.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2 In-Reply-To: <199812091619.LAA15213@gypsy.cad.gatech.edu>; from Jason Price on Wed, Dec 09, 1998 at 11:19:27AM -0500 Resent-Message-ID: <"4_Wgn2.0.cR6.UVgRs"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1973 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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