2

grepを使用してlsを実行すると、結果は正確に必要なものになります。dllのリスト。以下を参照してください。

$ ls -R | grep "dll$"
boost_chrono-vc90-gd-1_47.dll
boost_chrono-vc90-mt-gd-1_47.dll
boost_chrono-vc90-1_47.dll
boost_chrono-vc90-mt-1_47.dll
boost_date_time-vc90-gd-1_47.dll
boost_date_time-vc90-mt-gd-1_47.dll
boost_date_time-vc90-1_47.dll
boost_date_time-vc90-mt-1_47.dll
boost_filesystem-vc90-gd-1_47.dll
boost_filesystem-vc90-mt-gd-1_47.dll
boost_filesystem-vc90-1_47.dll
...

しかし、これらすべてのdllを../などの宛先にコピーしようとすると、エラーが発生し、ファイルがコピーされません。

$ cp `ls -R | grep "dll$"` ../
cp: cannot stat `boost_chrono-vc90-gd-1_47.dll': No such file or directory
cp: cannot stat `boost_chrono-vc90-mt-gd-1_47.dll': No such file or directory
cp: cannot stat `boost_chrono-vc90-1_47.dll': No such file or directory
cp: cannot stat `boost_chrono-vc90-mt-1_47.dll': No such file or directory
cp: cannot stat `boost_date_time-vc90-gd-1_47.dll': No such file or directory
cp: cannot stat `boost_date_time-vc90-mt-gd-1_47.dll': No such file or directory
cp: cannot stat `boost_date_time-vc90-1_47.dll': No such file or directory
cp: cannot stat `boost_date_time-vc90-mt-1_47.dll': No such file or directory
cp: cannot stat `boost_filesystem-vc90-gd-1_47.dll': No such file or directory
cp: cannot stat `boost_filesystem-vc90-mt-gd-1_47.dll': No such file or directory
...

以前はcygwinを使用したブーストビルドでこれを行うことができましたが、ブーストビルド1-47で機能しない理由がわかりません。

入力を確認してください。

4

1 に答える 1

3

dllのリストが表示されますが、それらがどのディレクトリにあるかはわかりません。ディレクトリ名は別の行に1回出力され、。によって除外されgrepます。

ls -R意味のあるものには使用できません。出力形式はスクリプトに適していません。find代わりに使用してください。このコマンド

find . -name "*.dll"

dllのフルパス名を出力します(使用する必要はありませんgrep)。このコマンド

find . -name "*.dll" -exec cp {} ..

..名前を出力する代わりに、ファイルをにコピーします。

于 2011-07-25T11:34:09.513 に答える