Gatting the age of a file in days is sometimes useful in scripts.
The date +%s command will give the current time in epoch seconds. It can be handily combined with -r, which causes date to use the modification time of a file rather than the current time. For example:
$ ls -l /etc/hosts
-rw-r--r-- 1 root root 3031 Mar 22 20:23 /etc/hosts
Our hosts file was last modified on March 22nd. Converting that date to "epoch" time, gives us the age of the file (since Jan 1970), in seconds:
Continue reading