代码之家  ›  专栏  ›  技术社区  ›  Sheldon

缺少-exec的参数

  •  0
  • Sheldon  · 技术社区  · 9 年前

    我遇到一个bash命令返回以下错误的问题:

    /usr/bin/find: missing argument to `-exec'
    

    我正在运行的实际命令是:

    /usr/bin/find /backup-directory/ -maxdepth 1 -type f -mtime +14 -printf "%f\n" -exec /usr/local/bin/aws s3 mv /backup-directory/{} s3://my-s3-bin/{}\;
    

    find命令在-exec之前一直正常工作,输出如下:

    /usr/bin/find /backup-directory/ -maxdepth 1 -type f -mtime +14 -printf "%f\n"
    20161030002947.Pg
    20161029002644.Pg
    20161027002705.Pg
    20161028002402.Pg
    20161031002440.Pg
    

    仅aws cli move命令和显式文件名move就可以按预期工作:例如,以下命令将把2016103002947.Pg从本地备份目录移动到s3 bin。

    /usr/local/bin/aws s3 mv /backup-directory/20161030002947.Pg s3://my-s3-bin/20161030002947.Pg
    

    当我将它们与-exec和{}参数放在一起时,我不知道为什么会中断。

    1 回复  |  直到 9 年前
        1
  •  5
  •   Cyrus    9 年前

    我建议更换

    {}\; 
    

    通过

    {} \;
    
    推荐文章
    Sheldon  ·  缺少-exec的参数
    9 年前