Get most recent file in a directory on Linux

前端 未结 21 2376
余生分开走
余生分开走 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条回答
  •  -上瘾入骨i
    2020-11-27 10:01

    ls -lAtr | tail -1

    The other solutions do not include files that start with '.'.

    This command will also include '.' and '..', which may or may not be what you want:

    ls -latr | tail -1

提交回复
热议问题