所以我想递归地搜索一个包含数千个文件夹的目录以查找特定的文件扩展名,并获取它的添加日期,然后按特定年份进行过滤。下面的代码有效,但有没有办法将其转换为单行代码?
获取所有以xml结尾的文件并写入tmp.txt
find . -name "*xml" >> tmp.txt
获取 tmp.txt 中所有文件的权限信息和时间戳信息
foreach i ( ` cat tmp.txt ` ) ls -ltrh $i >> tmp2.txt end
第 8 列包含年份日期,因此获取年份大于特定 2014 年的所有文件...
awk '$8 >=2014' tmp2.txt >> tmp3.txt
最佳答案
试试这个:
find . -type f -name '*xml' -newermt "2014-01-01" -ls
来自 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
关于linux - 我怎样才能将它组合成一个单行 - bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47871688/