我尝试将结果重定向到目录中,但它不允许我这样做。我究竟做错了什么 ?
find Documents/ -type f -regextype posix-egrep -regex ".+\.(doc|err|out)$" > Poubelle/
bash: Poubelle/: Is a directory
我想做的是移动 Poubelle 中列出的文件。
预先感谢您
最佳答案
就像 @Barmar 在评论中所说,您需要将 exec
命令与 mv
和 cp
一起使用。
您可以尝试使用以下命令:
将文件移动到目录:
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 .
关于linux 如何移动列出的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58180765/