【问题标题】:linux how to move listed files? [duplicate]linux如何移动列出的文件? [复制]
【发布时间】:2020-01-30 12:11:49
【问题描述】:

我试图将结果重定向到一个目录中,但它不允许我这样做。我究竟做错了什么 ?

find Documents/ -type f -regextype posix-egrep -regex ".+\.(doc|err|out)$" > Poubelle/

bash: Poubelle/: 是目录

我要做的是移动 Poubelle 中列出的文件。
提前谢谢你

【问题讨论】:

  • 你想实现什么? find 的输出是文件列表,只能重定向到文件。如果要复制结果,则不需要重定向。
  • 如果您尝试复制或移动find 列出的所有文件,您需要使用-exec cp-exec mv。您可能还想研究使用rsync 命令。

标签: linux ubuntu redirect


【解决方案1】:

就像@Barmar 在 cmets 中所说,您需要将exec 命令与mvcp 一起使用。

您可以尝试使用以下命令:

将文件移动到目录:

find Documents/ -type f -regextype posix-egrep -regex ".+\.(doc|err|out)$" -exec mv {} Poubelle/ \;

将文件复制到目录:

find Documents/ -type f -regextype posix-egrep -regex ".+\.(doc|err|out)$" -exec cp {} Poubelle/ \;

你也可以使用 rsync。更简单的形式是:

rsync source destination 

其他选项请阅读here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-26
    • 1970-01-01
    • 2014-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多