4 thoughts on “Get the name of the newest file in a directory on the linux shell

  • April 26, 2013 at 5:44 am
    Permalink

    how about ‘ls -ltr’ ?

    Reply
  • January 7, 2014 at 12:07 am
    Permalink

    And how to get the oldest file in a directory?

    Reply
    • March 21, 2014 at 7:13 pm
      Permalink

      ls -t | tail -n 1

      This will give you the oldest file or directory in the current working directory.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *