Get most recent file in a directory on Linux

前端 未结 21 2497
余生分开走
余生分开走 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:45

    try this simple command

    ls -ltq    | head -n 1
    

    If you want file name - last modified, path = /ab/cd/*.log

    If you want directory name - last modified, path = /ab/cd/*/

提交回复
热议问题