How do you CD change directory into the absolute path of a symbolic linked directory?
I'm currently in a symbolic link directory and I want to go up one level in the absolute path, but I cant as it will hit me back up to my home directory (~). I can do pwd -P to get the absolute path, but how do I pipe that result into the cd command? I always thought it was this: {}
Sample:
10:21:55 {master *} ~/ch$ pwd -P
/home/drupal/sites/all/themes/house
10:22:16 {master *} ~/ch$ pwd -P | cd {}
bash: cd: {}: No such file or directory
10:22:20 {master *} ~/ch$
This works for me:
cd `pwd -P`
You can also use cd -P
like this:
cd -P ~/ch
or if you're already in the symlinked directory:
cd -P .
You can insert the output of some command into the command line with the command substitution operator $(...)
.
For example, this will go to the physical current working directory (all symbolic links resolved):
cd $(pwd -P)
To go up one level (your ultimate goal, as I understood):
cd $(pwd -P)/..