aboutsummaryrefslogtreecommitdiff
path: root/diff-to-file.sh
blob: 077498a786a847e1444d1b621aa1bdf22d44a681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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}"