-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtime
More file actions
executable file
·70 lines (57 loc) · 1.24 KB
/
mtime
File metadata and controls
executable file
·70 lines (57 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#
# Michael Piko
# Description:
# Date created: 18-06-2014
# last modified: dd-mm-20yy
#-# Description:
#-# Compair two files based purly on their modified time. the files are usually
#-# in separate directories.
#-#
#-# Usage: mtime path/file1 path/file2
#-# Output: "older_file_number diff_in_seconds"
#-# Example:
#-# assume file2 is 14 seconds older run:
#-# mtime file1 file2
#-# prints "2 14"
#-# 2 being the second argument or file
#-# if they are both the same it prints "0 0"
# Script Variables:
#see setEnvironment.sh, functions.sh, and variables.sh for explainations
. setEnvironment.sh
#buildpath $LOGDIR
#cleandir $LOGDIR 2
#recordscriptrun $(basename $0) $LOGBASE
if ! enoughArgs 2 $#
then
usage
exit
fi
#VERBOSE=n
#if [ $# -eq 1 ] && [ $1 = "-v" ]
#then
# VERBOSE=y
#fi
# onScreen $VERBOSE "running"
FILE1=$1
FILE2=$2
if [ ! -e $FILE1 ]
then
echo "Cannot find $FILE1. Aborting"
elif [ ! -e $FILE2 ]
then
echo "Cannot find $FILE2. Aborting"
fi
F1MTIME=$(stat --printf=%Y "$FILE1")
F2MTIME=$(stat --printf=%Y "$FILE2")
AGEDIFF=$(expr $F2MTIME - $F1MTIME)
if [ $AGEDIFF -gt 0 ]
then
echo "1 $AGEDIFF"
elif [ $AGEDIFF -lt 0 ]
then
AGEDIFF=$(echo $AGEDIFF | sed 's/^-//')
echo "2 $AGEDIFF"
else
echo "0 0"
fi