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

Re: variable expansion which will remove a file extension



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote in
news:060317162338.ZM18794@xxxxxxxxxxxxxxxxxxxxxx: 

> ----------------
> h
>      Remove a trailing pathname component, leaving the head.  This
>      works like `dirname'.
> 
> r
>      Remove a filename extension of the form `.XXX', leaving the root
>      name.
> 
> e
>      Remove all but the extension.
> 
> t
>      Remove all leading pathname components, leaving the tail.  This
>      works like `basename'.

#!zsh
# test script
fred='/bin/path/fred.txt'
echo ${fred:e}
echo ${fred:t}
echo ${fred:r}
echo ${fred:h}
echo ${fred:h:h}
echo ${fred:t:r}

-- 
http://successtheory.com/ 100 FREE Success and Self-Improvement Tips



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