forked from NMAAHC/nmaahcmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diffFrameMD5
executable file
·45 lines (37 loc) · 1.92 KB
/
diffFrameMD5
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
#!/usr/bin/env bash
scriptdir="${0%/*}" # get dirname of $0 ($0 is the name of the current script)
. "${scriptdir}/nmaahcmmfunctions" ||
{ echo "Missing '${scriptdir}/nmaahcmmfunctions'. Exiting." ;
exit 1 ;} # The right side of && will only be evaluated if the exit status of the left side is zero.
# || is the opposite: it will evaluate the right side only if the left side exit status is nonzero.
_initialize_make # safe script termination process defined in nmaahcmmfunctions
## USAGE
_usage(){
echo
echo "$(basename "${0}")"
echo "This application will compare frame MD5s between two video files. It takes two text files as arguments. The text files must list the frame MD5s of the relevant video files. The results of a diff command will be displayed within the terminal."
echo "Usage: $(basename ${0}) file1.txt file2.txt"
echo
exit
}
[ "${#}" = 0 ] && _usage # if the command is run with no arguments then _usage is called
# getopts loop
OPTIND=1
while getopts ":h" OPT; do
case "${OPT}" in
h) _usage ;; # if the operator runs "[scriptname] -h" then the _usage text above will display in the terminal
*) echo "Invalid option -${OPTARG}" ; _usage ;; # if the operator tries to use an option other than the ones listed above, the _usage text will display in the terminal
esac
done
shift $(( ${OPTIND} - 1 ))
## SCRIPT ACTIONS
# log script beginning
_log -b
INPUT1="${1}" # $1 is the first argument (file that the operator supplied)
INPUT2="${2}" # $2 is the second argument (file that the operator supplied)
# compare the 6th field of each text file (which is where the checksums for each frame are expected to appear)
# diff --suppress-common-lines outputs only the lines that are NOT identical in both files
diff --side-by-side --width=200 --suppress-common-lines <(cat "${INPUT1}" | cut -d, -f 6) <(cat "${INPUT2}" | cut -d, -f 6)
# log script ending
_log -e
_report -g "diffFrameMD5 process complete."