Iterate through list of filenames in order they were created in bash

前端 未结 8 1751
深忆病人
深忆病人 2020-12-05 19:27

Parsing output of ls to iterate through list of files is bad. So how should I go about iterating through list of files in order by which they were first created

8条回答
  •  生来不讨喜
    2020-12-05 19:51

    How about a solution with GNU find + sed + sort?

    As long as there are no newlines in the file name, this should work:

    find . -type f -printf '%T@ %p\n' | sort -k 1nr | sed 's/^[^ ]* //'
    

提交回复
热议问题