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 的 boost build 可以做到这一点,但我不知道为什么现在它不适用于 boost build 1-47。

欣赏任何输入。

4

1 回答 1

3

您会看到一个 dll 列表,但您不知道它们位于哪些目录中。目录名称一次打印在单独的行上,并由 . 过滤掉grep

你不能ls -R用于任何有意义的事情。输出格式对脚本不友好。改为使用find。这个命令

find . -name "*.dll"

将打印您的 dll 的完整路径名(无需使用grep)。这个命令

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

将文件复制到..而不是打印它们的名称。

于 2011-07-25T11:34:09.513 回答