1

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)

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

1 Answers1

0

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.

Rhyuk
  • 404
  • 2
  • 8
  • 15