Skip to content

Instantly share code, notes, and snippets.

@shimarin
Created June 16, 2020 23:44
Show Gist options
  • Save shimarin/3ce1ae1a244a923aa2dc868ddce8c677 to your computer and use it in GitHub Desktop.
Save shimarin/3ce1ae1a244a923aa2dc868ddce8c677 to your computer and use it in GitHub Desktop.
script to get file age(seconds from mtime)
#!/bin/sh
if [ "$#" -eq 0 ] ; then
echo "Usage: $0 file" 1>&2
exit 1
fi
if [ ! -e $1 ];then
echo 9223372036854775807
exit 1
fi
CURRENT=`date +%s`
MTIME=`stat -c %Y $1`
echo $(( $CURRENT - $MTIME ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment