Quantcast
Channel: nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format (RSS/FEED)
Viewing all articles
Browse latest Browse all 2612

Find the oldest file in Unix or Linux file system757064617465 – nixCraft

$
0
0

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).


Viewing all articles
Browse latest Browse all 2612

Trending Articles