3 # this script takes two CSV files and ensures that they have the same
4 # contents, regardless of the order.
5 # if the function believes the two files are the same, then zero is returned.
6 function compare_csv_files()
11 if [ ! -f "$file1" -o ! -f "$file2" ]; then
12 echo "One of the files is missing; for this utility to work, both:"
15 echo "need to exist before running this script."
19 export temp_name1="$(mktemp "$TMP/zz_file1.XXXXXX")"
20 export temp_name2="$(mktemp "$TMP/zz_file2.XXXXXX")"
21 export temp_out="$(mktemp "$TMP/zz_differences.XXXXXX")"
23 # old code: should not be needed after 5.7.425 or so.
24 # right now we strip out realtime fields because of a problem in
25 # how they are shown (which is as a time and date).
26 #sort <"$file1" | grep -v "REALTIME" >"$temp_name1"
27 #sort <"$file2" | grep -v "REALTIME" >"$temp_name2"
29 # sort the two files so we can ignore the ordering.
30 sort <"$file1" >"$temp_name1"
31 sort <"$file2" >"$temp_name2"
33 diff "$temp_name1" "$temp_name2" >"$temp_out"
37 if [ -s "$temp_out" ]; then
38 echo "Differences seen in file:"
40 # return a failure exit value.
44 rm "$temp_name1" "$temp_name2" "$temp_out"
49 # simple run using above function.