CP 错误(与 ls 和 grep 结合使用)- cp: 无法统计

发布于 2024-11-26 07:08:57 字数 1431 浏览 4 评论 0原文

当我用 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 构建曾经能够做到这一点,但我不知道为什么现在它不适用于 boost 构建 1-47。

感谢任何输入。

When I do ls with grep, the result is exaxtly what I need: a list of dlls, see below:

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

But when I tried to copy all those dll to a destination say ../, I got errors and no files is copied:

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

I used be able to to this for my previous boost build using cygwin, but I don't know why now it's not working for boost build 1-47.

Apprecaite any input.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲸落 2024-12-03 07:08:57

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

您不能将 ls -R 用于任何有意义的事情。输出格式对脚本太不友好。请改用find。此命令

find 。 -name "*.dll"

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

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

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

You see a list of dlls, but you don't know in which directories they live. The directory name is printed on a separate line once, and filtered out by grep.

You cannot use ls -R for anything meaningful. The output format is too script-unfriendly. Use find instead. This command

find . -name "*.dll"

will print full path names of your dlls (no need to use grep). This command

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

will copy the files to .. instead of printing their names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文