Posted almost 9 years ago. Visible to the public.

Find the newest file from shell

This can be helpful when you need the latest file inside a directory for processing in a shell script:

ls -1tr * | tail -1

Used switches

The -1 switch makes ls return 1 file per line, -t orders by modification time and -r causes sorting from oldest to newest. tail -1 then returns the last line, containing the newest file's name.

If you require only a subset of files, adjust the "*" mask accordingly or use other switches of ls.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Arne Hartherz
Last edit:
over 4 years ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more