forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget_cprnc_diffs.sh
executable file
·56 lines (45 loc) · 1.68 KB
/
get_cprnc_diffs.sh
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
#!/bin/bash
# This script extracts lines from the output of cprnc that tell us
# which variables differ between two files
#
# Usage: get_cprnc_diffs filename
# ----------------------------------------------------------------------
# SET PARAMETERS HERE
# ----------------------------------------------------------------------
# maximum number of differences to extract from the cprnc output
maxdiffs=200
# ----------------------------------------------------------------------
# LOCAL FUNCTIONS DEFINED HERE
# ----------------------------------------------------------------------
# This function gets differences for one prefix (e.g., "RMS")
# Usage: get_diffs prefix
# (also uses $infile and $maxdiffs from the parent script)
function get_diffs {
prefix=$1
outfile=${infile}.${prefix}.$$
grep "$prefix" $infile > $outfile
numlines=`wc -l $outfile | awk '{print $1}'`
if [ $numlines -gt $maxdiffs ]; then
echo "WARNING: Too many instances of $prefix - only printing last $maxdiffs"
tail -$maxdiffs $outfile
else
cat $outfile
fi
rm $outfile
}
# ----------------------------------------------------------------------
# BEGIN MAIN SCRIPT
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Handle command-line arguments
# ----------------------------------------------------------------------
if [[ $# -ne 1 ]]; then
echo "Usage: get_cprnc_diffs filename"
exit 1
fi
infile=$1
# ----------------------------------------------------------------------
# Do the processing
# ----------------------------------------------------------------------
get_diffs RMS
get_diffs FILLDIFF