【问题标题】:Is there any copy update alternative command?是否有任何复制更新替代命令?
【发布时间】:2013-10-11 09:09:56
【问题描述】:

我目前正在使用 BusyBox v1.16.2 并且 cp 命令不提供更新选项:

...
-u, --update
copy  only  when  the  SOURCE file is newer than the destination file
or when the destination file is missing

还有其他选择吗?

我会考虑使用 find --newer 参数,但我正在尝试弄清楚如何做到这一点(经过几次尝试......)。

BusyBox v1.16.2 multi-call binary.

Usage: cp [OPTIONS] SOURCE DEST

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY

Options:
    -a      Same as -dpR
    -R,-r   Recurse
    -d,-P   Preserve symlinks (default if -R)
    -L      Follow all symlinks
    -H      Follow symlinks on command line
    -p      Preserve file attributes if possible
    -f      Force overwrite
    -i      Prompt before overwrite
    -l,-s   Create (sym)links

【问题讨论】:

  • 我看到cp-n, --no-clobber ---> do not overwrite an existing file。对你有用吗?
  • @fedorqui Busybox 提供了一个有限版本的 cp。我为busybox cp 添加了当前选项。所以没有 -n 选项。

标签: linux unix embedded cp busybox


【解决方案1】:
test file1 -ot file2 && cp file2 file1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 1970-01-01
    • 2016-01-25
    • 2015-02-14
    相关资源
    最近更新 更多