我试图在Solaris OS上复制一个链接,但发现它不是简单地复制链接而是复制链接指向的目录/文件的全部内容?这在AIX,HP-UX,Linux等其他操作系统中并不存在.
这是Solaris OS的正常行为吗?
查理接近,你想要的-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.