Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the simplest way to output file ages instead of filedates by ls command?

Like "1 hour", "2 days", "3 weeks", etc.

(Sometimes file age is much more significant than date)

share|improve this question
Gnome's Nautilus does something similar. Perhaps you can check how it's done there? – Bram Jun 13 '12 at 19:22

I get the UNIX-Systemdate in seconds with NOW=date +%s Then I get the UNIX-Timestamp of the file with OLD=stat -c %Z filename

And finally I get the age by expr $NOW - $OLD.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.