【问题标题】:Moving multiple files with find and tar on Ubuntu在 Ubuntu 上使用 find 和 tar 移动多个文件
【发布时间】:2015-09-11 03:32:00
【问题描述】:

我正在尝试使用此命令将某些 .ipynb 文件从一个目录移动到另一个目录:

find . -name "*failed.ipynb" -print0 | xargs -0 tar cvf "-" | (cd ./fails ; tar xfp "-")

该命令在 OS X 和 CentOS 上运行良好,但是当在 Ubuntu 机器上的 Travis CI 上运行时,它会在文件名中有空格的情况下失败。

我认为 -print0-0 选项应该可以解决这个问题,还有其他我做错了吗?

编辑 输出如下所示:

$ source ./scripts/runipy.sh
Processing science/Transients/Followup Observatories.ipynb
science/Transients/Followup Observatories.ipynb failed.

The following notebooks failed
tar: ./science/Transients/Followup: Cannot stat: No such file or directory
tar: Observatories.ipynb-failed.ipynb: Cannot stat: No such file or directory

.ipynb 文件的文件名中有空格会失败。

谢谢

【问题讨论】:

  • 失败是什么样子的?

标签: ubuntu find tar travis-ci


【解决方案1】:

你能用cpio 代替吗?它从 stdio 读取文件名,因此空格没有问题。 (虽然可能有换行符,在这种情况下有 -0 选项。)

find . -name "*failed.ipynb" | cpio -pd ./fails

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多