1 #From: "Grigoriy Strokin" <grg@philol.msu.ru>
2 #Newsgroups: comp.unix.shell
3 #Subject: fast basename and dirname functions for BASH/SH
4 #Date: Sat, 27 Dec 1997 21:18:40 +0300
6 #Please send your comments to grg@philol.msu.ru
16 local dir="${1%${1##*/}}"
17 [ "${dir:=./}" != "/" ] && dir="${dir%?}"
21 # Two additional functions:
22 # 1) namename prints the basename without extension
23 # 2) ext prints extension of a file, including "."
28 local name0="${name%.*}"
29 echo "${name0:-$name}"
34 local name0="${name%.*}"
35 local ext=${name0:+${name#$name0}}