Linux.com

Re: Four ways to extract the current directory name

Posted by: Anonymous [ip: unknown] on November 08, 2007 02:24 PM
Totally disagree with you, I have been doing C and bash programming for a long time, and sometimes (not very often really) I need the current directory name, I always used basename `pwd` to extract it, but thanks to this tutorial I found out the much better alternative echo ${PWD##*/}, I use parameter substitution a lot, but never thought about this one. With this choice no overhead is produce when running the script, perhaps to you this little overhead doesn't matter, but most of the C programmers or good programmers in any language are always searching ways to tweak a little bit more, and a little bit more and so many times until the program runs as smooth as possible.
Good article.

#

Return to Four ways to extract the current directory name