How to find the oldest and newest file in directory in Linux shell

Last updated on April 29th, 2020 at 07:13 am

Complex way, but allowed you to customise the output.

find /home/juzhax/ -type f -printf '%T- %p\n' | sort | head -n 1

Simple and shorter way

ls -lt | tail -1

Extra: Find the newest files in shell

ls -ltr | tail -1

Tags:

Discover more from Juzhax Technology

Subscribe now to keep reading and get access to the full archive.

Continue reading