This is a command-line trick from a book-"The Productive Programmer":
pushd `which java`/..
The author says this command can temporarily go the directory where the executable command java lives.
When I typed this command in Linux, Bash complained that:
bash: pushd: /usr/bin/java/..: Not a directory
I also tried to change directory to /usr/bin/java/..
directly:
$ pushd /usr/bin/java/..
bash: pushd: /usr/bin/java/..: Not a directory
Why did I fail? Why cannot change to a directory using /..
? How to modify this command to fulfill the same task?
path/..
depends on the path being a directory (where '..' is a reference to its parent). – Skaperen Dec 24 '15 at 13:23