#!/usr/bin/env bash # Outputs the seconds since the thing identified by the first argument # was last modified (not created). ageof() { local path="$1" if [[ -z "$path" ]]; then echo 'usage: ageof ' return 1 fi echo $(( $(date +%s) - $(date -r "$path" +%s) )) } ageof "$@"