在写 shell 脚本的时候,有时我们需要得到当前目录的名称,pwd 命令可以返回当前目录的完整路径,而不是目录名,如果要得到目录名
即获得/home/vincent/xen 中的xen,可以有以下几种方法:
1)basename `pwd`
2)pwd | rev | awk –F \/ '{print $1}' | rev
3)pwd | sed 's,^\(.*/\)\?\([^/]*\),\2,'
Vincent's Ray Tracing"... We slept on floors. We waded across rivers." |