我有个剧本:
newerthan="2016-02-08"
olderthan="2016-04-29"
find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -ls此列表文件:
16481 0 -r--r--r-- 1 root root 4096 Mar 16 11:41 /sys/module/sunrpc/srcversion
16482 0 -r--r--r-- 1 root root 4096 Mar 13 04:42 /sys/module/sunrpc/initstate
16483 0 -r--r--r-- 1 root root 4096 Mar 16 11:41 /sys/module/sunrpc/refcnt
16485 0 -r--r--r-- 1 root root 4096 Mar 17 11:41 /sys/module/sunrpc/sections/.note.gnu.build-id
16486 0 -r--r--r-- 1 root root 4096 Mar 12 11:41 /sys/module/sunrpc/sections/.text是否可以按日期、结果进行排序?
发布于 2016-04-29 17:02:29
如果要按排序顺序打印文件名和日期:
find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf "%T+\t%p\n" | sort如果只想按排序顺序打印文件名:
find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf "%T+\t%p\n" | sort | awk '{print $2}'发布于 2016-04-29 16:50:43
这将返回日期排序、时间戳限制、显示文件名的列表。
find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf '%T@ %p\n' | sort -k 1 -n | sed 's/^[^ ]* //'如果需要这些其他列,则可以更改printf和排序参数,以显示更多的列并按位置排序,而不是按列排序。
https://stackoverflow.com/questions/36943314
复制相似问题