Linux 如何使用按创建日期排序的find命令&;时间递归?
对于这个问题,我已经尝试了很多次。Linux 如何使用按创建日期排序的find命令&;时间递归?,linux,bash,shell,command,Linux,Bash,Shell,Command,对于这个问题,我已经尝试了很多次。 find命令结果与列表顺序无关 如何根据find recursive命令结果中的创建日期和时间使用目录列表 ls -lc 这很好,但不是递归的方式 find . -type f -iname "*.txt" -exec ls -lc {} \; 这不管用 find . -type f -iname "*.txt" | sort -n 这也只是基于名称 来自的解决方案与来自问题的命令相结合: find . -type f -iname "*.txt
find命令结果与列表顺序无关 如何根据find recursive命令结果中的创建日期和时间使用目录列表
ls -lc
这很好,但不是递归的方式
find . -type f -iname "*.txt" -exec ls -lc {} \;
这不管用
find . -type f -iname "*.txt" | sort -n
这也只是基于名称 来自的解决方案与来自问题的命令相结合:
find . -type f -iname "*.txt" -printf "%T@ %Tc %p\n" | sort -n
有关命令的变化,请参见不同的答案。引用参考问题的解释:
find . -type f -iname "*.txt" -printf "%T@ %Tc %p\n" | sort -n
printf
参数来自:
:文件的上次修改时间,格式由%Tk
指定k
:自1970年1月1日00:00 GMT起的秒数,带小数部分@
:地区的日期和时间(美国东部时间1989年11月4日星期六12:02:33)c
:文件名%p
find . -type f -iname "*.txt" -exec stat -f '%B %m %N' {} \; | rev | cut -d '/' -f 1 | rev | sort -n
@酷乔布斯:不需要。您在标签中指定您正在搜索Linux而不是MacOS的解决方案。哦,这是我的错误,对不起!我忘了添加macos:-)我找到了如下解决方案!!在macos上#-----------------------------------------------------------------------------------------查找-键入f-iname“*.txt”-exec stat-f'%B%m%N'{}\|rev | cut-d'/'-f1 | rev | sort-n#------------------------------------------------------------------------------------------------------------