file-age now BSD compatible

This commit is contained in:
ville rantanen
2017-06-09 09:52:05 +03:00
parent cdbe32d534
commit 2e8bd83dcd
2 changed files with 5 additions and 2 deletions

View File

@@ -23,7 +23,10 @@ STATFILE="$1"
test -e "$STATFILE" || { echo File "$STATFILE" does not exist >&2; exit 1; }
UNITS=${2:-S}
created=$( stat -c %Y "$STATFILE" )
case $OSTYPE in
darwin*) created=$( stat -f %c -t %s "$STATFILE" ) ;;
linux*) created=$( stat -c %Y "$STATFILE" ) ;;
esac
now=$( date +%s )
age=$(( $now - $created ))