Get most recent file in a directory on Linux

前端 未结 21 2388
余生分开走
余生分开走 2020-11-27 09:24

Looking for a command that will return the single most recent file in a directory.

Not seeing a limit parameter to ls...

21条回答
  •  执笔经年
    2020-11-27 09:43

    Finding the most current file in every directory according to a pattern, e.g. the sub directories of the working directory that have name ending with "tmp" (case insensitive):

    find . -iname \*tmp -type d -exec sh -c "ls -lArt {} | tail -n 1" \;
    

提交回复
热议问题