![](/img/trans.png)
[英]Shell script to find files after certain modified date and sort them in order of modified date
[英]Find and sort files by date modified
我知道網上有很多關於這個問題的答案。 但是,我想知道這種替代解決方案是否可行:
ls -lt `find . -name "*.jpg" -print | head -10`
我當然知道這只會給我前10個結果。 我問的原因是因為我不確定ls
是否針對find
每個結果分別執行。 謝謝
在您的解決方案中:
ls
將在評估find
之后執行 find
可能會產生太多的結果供ls
處理,在這種情況下,您可能需要查看xargs
命令 這應該更好地工作:
find . -type f -print0 | xargs -0 stat -f"%m %Sm %N" | sort -rn
命令的三個部分對此:
xargs
處理(長)文件列表,並輸出修改的unixtime,人類可讀時間和每個文件的文件名 主要技巧是將上次修改文件時的數字unixtime添加到各行的開頭,然后對其進行排序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.