当前位置:  开发笔记 > 运维 > 正文

复制Solaris中的符号链接

如何解决《复制Solaris中的符号链接》经验,为你挑选了1个好方法。

我试图在Solaris OS上复制一个链接,但发现它不是简单地复制链接而是复制链接指向的目录/文件的全部内容?这在AIX,HP-UX,Linux等其他操作系统中并不存在.

这是Solaris OS的正常行为吗?



1> Martin Carpe..:

查理接近,你想要的-L,-H-P标志与-R标志(可能只是-R -P).类似的标志存在chmod(1)chgrp(1).我已经粘贴了下面手册中的摘录.

例:

$ touch x
$ ln -s x y 
$ ls -l x y 
-rw-r--r--   1 mjc      mjc            0 Mar 31 18:58 x
lrwxrwxrwx   1 mjc      mjc            1 Mar 31 18:58 y -> x
$ cp -R -P y z
$ ls -l z
lrwxrwxrwx   1 mjc      mjc            1 Mar 31 18:58 z -> x
$ 

或者,普通的旧tar会默认使用符号链接,甚至是Solaris附带的古老版本:

tar -cf foo | ( cd bar && tar -xf - )

(其中foo是符号链接或包含符号链接的目录).

 /usr/bin/cp -r | -R [-H | -L | -P] [-fip@] source_dir... target

 ...

 -H    Takes actions based on the type and  contents  of  the
       file  referenced  by  any symbolic link specified as a
       source_file operand.

       If the source_file operand is a symbolic link, then cp
       copies  the  file  referenced by the symbolic link for
       the source_file  operand.  All  other  symbolic  links
       encountered  during  traversal of a file hierarchy are
       preserved.


 -L    Takes actions based on the type and  contents  of  the
       file  referenced  by  any symbolic link specified as a
       source_file operand or any symbolic links  encountered
       during traversal of a file hierarchy.

       Copies files referenced by  symbolic  links.  Symbolic
       links encountered during traversal of a file hierarchy
       are not preserved.


 -P    Takes actions on any  symbolic  link  specified  as  a
       source_file  operand  or any symbolic link encountered
       during traversal of a file hierarchy.

       Copies symbolic links. Symbolic links encountered dur-
       ing traversal of a file hierarchy are preserved.

推荐阅读
刘美娥94662
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有