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; } test -e "$STATFILE" || { echo File "$STATFILE" does not exist >&2; exit 1; }
UNITS=${2:-S} 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 ) now=$( date +%s )
age=$(( $now - $created )) age=$(( $now - $created ))

2
rc
View File

@@ -1,6 +1,6 @@
# source me to enable tools # source me to enable tools
TOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) ) TOOLSPATH=$( realpath $( dirname "$BASH_SOURCE" ) )
PATH=$PATH:"$TOOLSPATH"/bin PATH=$PATH:"$TOOLSPATH"/bin
[[ "$1" = "-f" ]] && PATH="$TOOLSPATH"/bin:$PATH [[ "$1" = "-f" ]] && PATH="$TOOLSPATH"/bin:$PATH