How to make a shell script do not resolve a symbolic link
Hi,
In my shell script I want to do a ls on the parent directory to a symlink in the path ls -1 -tr $my_dir/../../../ the second directory above $my_dir is a symbolic link, and when a .. is done, it goes to the parent directory of the path which the symbolic link is referring to. I do not want to go to the referred path, but to the actual parent of the symlink. How to achieve this. Please advice. |
Do you know how to do this at the command line? What have you googled and started with? We like to see some effort on any OP's part and then offer assistance.
|
One workaround is to first unlink the file at beginning and link it again at the end, like:-
Code:
#!/bin/bash |
cd $my_dir/,,/,,/ to ignore symbolic link and go to the symbolic link parent directory
Still,
I am struggling with the same question, I did not get a way to ignore resolving the symbolic link in a relative path and go to the actual parent directory of the symbolic link. I have code ready by parsing the string using SED, but I felt, there will be an option to get through this directly using cd /ls . Please advice. |
In bash you can use
Code:
set +P Code:
(cd $my_dir/../../../ && ls) Code:
my_path=$(cd $my_dir/../../../ && pwd) |
All times are GMT -5. The time now is 06:47 AM. |