Find the oldest file in Unix or Linux file system

Find the oldest file in Unix or Linux file system

So I wanted to know the oldest file on my Debian Linux box.

find / -type f -printf '%T+ %pn' | sort | head -n 1
Here is an another example for /etc/
find /etc/ -type f -printf '%T+ %pn' | sort | head -n 10

Find the top 10 oldest file in a directory tree on GNU/Linux

Find the top 10 oldest file in a directory tree on GNU/Linux

So find command finds all files in / and print it with a special format. The %T+ (in -printf) means file’s last modification date and time in separated by +, for example ‘2004-04-28+22:22:05.0’. This is a GNU extension and may not work on other BSD/find or any other version of find. The %p indicts the file name. The sort command sorted input and passed it to head to display the oldest file on my GNU/Linux system. The sort command sorted input and passed it to head to display the oldest file on my GNU/Linux system. Cool, eh?

(Credit: Ubuntu forums).

Halal Vitamins

Powered by WPeMatico

Leave a Reply

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