aboutsummaryrefslogtreecommitdiff
path: root/diff-to-file.sh
diff options
context:
space:
mode:
Diffstat (limited to 'diff-to-file.sh')
-rw-r--r--diff-to-file.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/diff-to-file.sh b/diff-to-file.sh
new file mode 100644
index 0000000..077498a
--- /dev/null
+++ b/diff-to-file.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+if test "${#}" -ne 2; then
+ printf "%s\n" \
+ "compare two files and output the difference" \
+ "usage: $(basename $0) <file1> <file2>"
+ exit 1
+fi
+
+if ! command -v comm &>/dev/null; then
+ printf "%s\n" "comm not found"
+ exit 1
+fi
+
+output="${1}__not_in__${2}"
+comm -23 <(sort "${1}") <(sort "${2}") > "${output}"
+printf "%s\n" "results of what is in ${1} and not in ${2} in ${output}"