Perlist at blogspot
2014/11/19
How many hours ago was the file changed?
FILE="/path/to/file"
CURRENT_DATE=$(date +%s)
PREVIOUS_DATE=$(date -d "$(ls -ld $FILE | awk '{print $6,$7,$8}')" "+%s")
DELTA=$(( CURRENT_DATE - PREVIOUS_DATE ))
DELTA_HOURS=$(echo "scale=2; $DELTA / 3600" | bc)
echo $DELTA_HOURS hours ago
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment