diff options
author | heqnx <root@heqnx.com> | 2025-05-12 20:20:51 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-05-12 20:20:51 +0300 |
commit | 3ed7425efe5ad0bec184897c3eaee6c88d84554e (patch) | |
tree | 96b7054ba5f1f5dbed2b3bae9f76aaf7368adaed | |
parent | ef9a8d3018cb9e97cc85f5d052c7cdfdd2e34469 (diff) | |
download | gists-3ed7425efe5ad0bec184897c3eaee6c88d84554e.tar.gz gists-3ed7425efe5ad0bec184897c3eaee6c88d84554e.zip |
added diff-to-file.sh
-rw-r--r-- | diff-to-file.sh | 17 |
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}" |