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+ %p\n' | sort | head -n 1
Here is an another example for /etc/
find /etc/ -type f -printf '%T+ %p\n' | 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).

In Category: Link

Vivek Gite

Vivek Gite, nixCraft creator, and professional Unix sysadmin/DevOps is obsessed with optimizing the servers and making sure data center stays online 24x7.

Show 0 Comments
No comments yet. Be the first.

Leave a Comment