3

Solaris OS でリンクをコピーしようとしていますが、単にリンクをコピーするのではなく、リンクが指しているディレクトリ/ファイルの内容全体をコピーすることがわかりました。これは、AIX、HP-UX、Linux などの他の OS にはありません。

これは Solaris OS の正常な動作ですか?

4

4 に答える 4

7

チャーリーは近かったので、-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.
于 2009-03-31T17:04:36.290 に答える
1

あなたはcp -P私が信じていることを望んでいます(私は今のところsolarisボックスを手元に持っていないので、マニュアルページをチェックしてください.)私はそれがSystem V主義であるとかすかに疑っていますが、それを誓うつもりはありません.

于 2009-03-31T16:10:36.870 に答える
0

単一のシンボリックリンクを複製しようとしているようです。

あなたはただやりたいかもしれません:


link_destination=`/bin/ls -l /opt/standard_perl/link|awk '{print $10}'`
ln -s $link_destination /opt/standard_perl/link_new

ディレクトリ階層をコピーしようとしている場合、GNU ツール (または rsync) なしでは、これを行うのは一般的に非常に困難です。多くの場合に機能する解決策はありますが、遭遇する可能性のあるすべての種類のファイル名を持つすべての「標準」UNIX で機能する解決策はありません。これを定期的に行う場合は、GNU coreutils、find、cpio、tar、および rsync もインストールする必要があります。

于 2009-05-21T03:11:18.997 に答える
0

cpio はあなたのためにトリックを行いますか?

于 2009-03-31T16:10:04.643 に答える