简体   繁体   English

当路径包含符号链接时,如何在unix / linux中移回一个目录?

[英]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.

相关问题 如何比较unix(Linux)中的2个符号链接? - How to compare 2 symbolic links in unix (Linux)? 在Linux和Windows之间切换时如何处理符号链接? - How to deal with symbolic links when going between Linux and Windows? 如何检测何时在Linux中的符号链接目录中修改了一个文件 - How to detect when one file is modified inside a symbolic link directory in Linux 如何在LINUX的另一个目录中有选择地创建指向特定文件的符号链接? - How do I selectively create symbolic links to specific files in another directory in LINUX? 使用符号链接在Linux中将文件从一个位置移动到另一位置 - Move files from one location to another in Linux using Symbolic link 用于符号链接的Linux命令文件 - Linux command file for symbolic links 如何将符号链接文件从Linux复制到Windows,然后再复制到Linux,但仍将其保留为符号链接 - How to copy symbolic link file from Linux to Windows and then back to Linux but still keeping it as a symbolic link 需要使用 unix 脚本将文件名移动到带有文件路径的目录中 - Need to move file names in a directory with path to a file using unix script 批量移动文件并在Linux目录中的位置处创建链接 - Move files in bulk and create links in their place in the directory in linux Unix / Linux符号链接是否支持回退? - Does Unix/Linux symbolic link support fallback?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM