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

Re: Notes on bash(1)



On Wed, 9 Dec 1998, Jason Price wrote:

> 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?

Well, it is in the info-pages, section on modifiers. Excerpt:
`h'
     Remove a trailing pathname component, leaving the head.

`r'
     Remove a trailing suffix of the form ``.'XXX', leaving the
     basename.

`e'
     Remove all but the suffix.

`t'
     Remove all leading pathname components, leaving the tail.
[...]

So:

swen@kreta <~>: foo=/usr/local/bin/mumble
swen@kreta <~>: echo ${foo:t}
mumble
swen@kreta <~>: 

Hope this helps.

--Swen




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