Solaris OS でリンクをコピーしようとしていますが、単にリンクをコピーするのではなく、リンクが指しているディレクトリ/ファイルの内容全体をコピーすることがわかりました。これは、AIX、HP-UX、Linux などの他の OS にはありません。
これは 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.
あなたはcp -P
私が信じていることを望んでいます(私は今のところsolarisボックスを手元に持っていないので、マニュアルページをチェックしてください.)私はそれがSystem V主義であるとかすかに疑っていますが、それを誓うつもりはありません.
単一のシンボリックリンクを複製しようとしているようです。
あなたはただやりたいかもしれません:
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 もインストールする必要があります。
cpio はあなたのためにトリックを行いますか?