Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
BASH脚本。如何在指定的修改日期之前触摸每个文件_Bash_Find_Touch - Fatal编程技术网

BASH脚本。如何在指定的修改日期之前触摸每个文件

BASH脚本。如何在指定的修改日期之前触摸每个文件,bash,find,touch,Bash,Find,Touch,因此,我希望能够进入一个文件夹,并更新其中每个文件的“上次修改”数据 到目前为止,我认为我应该使用: touch --date "2012-12-31" /tmp/date find /filestotouch -type f -not -newer /tmp/date 这应该列出所有匹配的文件。现在,我需要做一个循环,还是有一种简单的方法将这些数据传递给touch并让它完成所有操作?尝试“查找”命令: find /filestotouch -iname "*.type" -mtime +60

因此,我希望能够进入一个文件夹,并更新其中每个文件的“上次修改”数据

到目前为止,我认为我应该使用:

touch --date "2012-12-31" /tmp/date
find /filestotouch -type f -not -newer /tmp/date
这应该列出所有匹配的文件。现在,我需要做一个循环,还是有一种简单的方法将这些数据传递给touch并让它完成所有操作?

尝试“查找”命令:

find /filestotouch -iname "*.type" -mtime +60 -exec touch "{}" \;
上述命令将提取60天前修改过的所有文件。

请尝试“查找”命令:

find /filestotouch -iname "*.type" -mtime +60 -exec touch "{}" \;
上述命令将提取60天前修改过的所有文件。

有两个选项:

  • 添加选项
    -exec
    :<代码>-not-newer/tmp/date-exec touch“{}”
  • 管道到
    xargs
    :<代码>-不-更新/tmp/date-print0 | xargs-0触摸屏
  • 有两种选择:

  • 添加选项
    -exec
    :<代码>-not-newer/tmp/date-exec touch“{}”
  • 管道到
    xargs
    :<代码>-不-更新/tmp/date-print0 | xargs-0触摸屏

  • 使用
    -exec
    开关来查找duse使用
    -exec
    开关来查找dedited:
    {}
    在某些shell中是特殊字符,因此请使用引号对其进行转义。@AaronDigulla Nice one-这是您第二次编辑我的帖子-这很好。:)由于问题要求的是
    -not-newer
    ,我认为应该是
    -mtime+60
    。请参见编辑:
    {}
    在某些shell中是特殊字符,请使用引号对其进行转义。@aarondigula Nice one-这是您第二次编辑我的帖子-这很好。:)由于问题要求的是
    -not-newer
    ,我认为应该是
    -mtime+60
    。这两项工作都看了,但你的先被推荐了,所以我觉得有义务给你荣誉!谢谢。两份都是,但你的是先推荐的,所以我觉得有义务给你荣誉!非常感谢。