Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: string match simplification?
This seems ok: (and never mind deciding on how long the extension
can be):
#!/usr/bin/zsh
filename=$1
extension=${filename:e}
# just in case there's a trailing dot: don't remove in unless there
is an extension.
[ "$extension" ] && filename="${filename%.*}"
echo filename is: $filename
echo extension is: .$extension # I'll keep the dot on the extension.
That's :r. (It stands for "root".)
There's also :h and :t (head and tail) for
pathnames: :h is the directory component, and :t the
bare filename. So if filename=/foo/bar/baz.txt you have:
Such resources! Gotta lock myself in a punishment cell and read
the manual just to know what's available.
Thanks guys. There's no better help anywhere.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author