我怎样才能将它组合成一个单行 - bash

e9e*_*e9s 1 linux bash shell

因此,我希望以递归方式搜索具有数千个文件夹的目录以获取特定的文件扩展名,并获取添加的日期,然后按特定年份过滤.下面的代码有效但有没有办法可以转换为单行代码?

  1. 获取所有以xml结尾的文件并写入tmp.txt

    find . -name "*xml" >> tmp.txt  
    
    Run Code Online (Sandbox Code Playgroud)
  2. 获取tmp.txt中所有这些文件的权限信息和时间戳信息

    foreach i ( ` cat tmp.txt ` )
    ls -ltrh $i >> tmp2.txt
    end
    
    Run Code Online (Sandbox Code Playgroud)
  3. 第8列包含日期作为年份,因此获取年份大于特定2014年的所有文件...

    awk '$8 >=2014' tmp2.txt >> tmp3.txt
    
    Run Code Online (Sandbox Code Playgroud)

Pav*_*vel 5

试试这个:

find . -type f -name '*xml' -newermt "2014-01-01" -ls
Run Code Online (Sandbox Code Playgroud)

来自man find:

   -newerXY reference
          Succeeds if timestamp X of the file being considered is newer
          than timestamp Y of the file reference.   The letters X and Y
          can be any of the following letters:

          a   The access time of the file reference
          B   The birth time of the file reference
          c   The inode status change time of reference
          m   The modification time of the file reference
          t   reference is interpreted directly as a time
Run Code Online (Sandbox Code Playgroud)