当然,可以获取输出find . -type f | xargs ls -l
并将其传输到 Python 脚本,该脚本将对行进行排序并输出前 20 名。
但还有比这更快的事情吗?
答案1
在 Mac OS X (10.10.2) 上,尝试此操作
find . -xdev -type f -print0 | xargs -0 stat -f "%m%t%Sm %N"
stat
或直接运行
stat -f "%m%t%Sm %N" /path
从man stat
In order to determine the three files that have been modified most recently, you could use the following format: > stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2- Apr 25 11:47:00 2002 /tmp/blah Apr 25 10:36:34 2002 /tmp/bar Apr 24 16:47:35 2002 /tmp/foo
您可以轻松地将 3 替换为 20 (-:
答案2
find . -xdev -type f -printf "%T@ %Tc %p\n" | sort -n | tail -20