Listing files in date order with spaces in filenames

前端 未结 4 1092
一整个雨季
一整个雨季 2020-12-10 23:00

I am starting with a file containing a list of hundreds of files (full paths) in a random order. I would like to list the details of the ten latest files in that list. This

4条回答
  •  情书的邮戳
    2020-12-10 23:49

    Instead of "one or more blank characters", you can force bash to use another field separator:

    OIFS=$IFS
    IFS=$'\n'
    
    ls -las -t $(cat list-of-files.txt) | head -10
    IFS=$OIFS
    

    However, I don't think this code would be more efficient than doing a loop; in addition, that won't work if the number of files in list-of-files.txt exceeds the max number of arguments.

提交回复
热议问题