How may I detect the name of the directory (or better yet the entire path) in which my shell script is run?
seems to work thanks
goe
2009-11-30 02:06:29
And if you do want just the directory's name, instead of the full path, read man basename too.
Roger Pate
2009-11-30 02:46:04
+1
A:
This is not as trivial as it looks like. Check out this question and this
Pekka
2009-11-30 02:46:28
A:
This, I believe, is the most portable way:
dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
glenn jackman
2009-11-30 14:06:55