gpt4 book ai didi

solaris - 复制 Solaris 中的符号链接(symbolic link)

转载 作者:行者123 更新时间:2023-12-02 04:06:44 36 4
gpt4 key购买 nike

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

这是 Solaris 操作系统的正常行为吗?

最佳答案

Charlie 很接近,您需要 -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 会愉快地使用符号链接(symbolic link),甚至是 Solaris 附带的古老版本:

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

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

 /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.

关于solaris - 复制 Solaris 中的符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/701730/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com