[英]How to move one directory back in unix / linux when path contains symbolic links?
I have created a symbolic link to a deeply nested directory. 我已经创建了一个指向深层嵌套目录的符号链接。 Using symbolic link i can move to that directory from my home directory. 使用符号链接我可以从我的主目录移动到该目录。 I want to move one directory back from the target directory but the shell comes back to the home directory. 我想从目标目录移回一个目录,但shell返回到主目录。
[root@pe1800xs ~]# pwd
/root
[root@pe1800xs ~]# mkdir -p abc/def/ghi/jkl/mno/pqr
[root@pe1800xs ~]# ln -s abc/def/ghi/jkl/mno/pqr/ xyz
[root@pe1800xs ~]# cd xyz
[root@pe1800xs xyz]# pwd
/root/xyz
[root@pe1800xs xyz]# pwd -P
/root/abc/def/ghi/jkl/mno/pqr
[root@pe1800xs xyz]# cd ..
[root@pe1800xs ~]# pwd
/root
What I want to achieve is that when I do cd..
in pqr
directory the shell should come to mno
directory. 我想要实现的是,当我在pqr
目录中执行cd..
,shell应该进入mno
目录。
You must use 你必须使用
cd -P xyz
to enter into that directory to follow the original structure of folders, then you can move as you wish because you have resolved the link to the real path. 要进入该目录以跟踪文件夹的原始结构,您可以根据需要移动,因为您已经解析了指向真实路径的链接。
你必须传递-P
选项:
cd -P ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.