按创建日期查找和排序结果

Jus*_*tin 8 linux find sort

我怎样才能对结果进行排序find?我想按创建日期按 asc 排序?

find /docs -type f | sort
Run Code Online (Sandbox Code Playgroud)

按文件名而不是创建日期排序。谢谢。

qua*_*nta 12

AFAIK,Linux 不记录创建时间,所以简短的回答是你不能。

对于修改时间,试试这个:

$ find /docs -type f -printf '%T@ %p\n' | sort -k1 -n
Run Code Online (Sandbox Code Playgroud)

或者:

$ find /docs -type f -print0 | xargs -0 stat -c "%y %n" | sort
Run Code Online (Sandbox Code Playgroud)

  • 你也打我吧!Justin,有关 ctime 实际含义的一些讨论,请查看 http://www.perlmonks.org/?node_id=741616 (2认同)