X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=teeu;h=948169dbffdd190d66a2cb502ec0807800ef4012;hb=ea655d17a5e11dd740574d0a1d5ca2401d5cf063;hp=5be4b7688b3d14310a79efb5749e643cc3704027;hpb=ad53fa76300d63ff54840321af31ebcb6bb3ef9a;p=tee-unique diff --git a/teeu b/teeu index 5be4b76..948169d 100755 --- a/teeu +++ b/teeu @@ -9,22 +9,19 @@ Tee unique. Append each LINE or if none, each stdin line to FILE if it does not [-h|--help] display this message" - if [[ $1 == --help || $1 == -h ]]; then echo "$help" return fi - + if (( ${#@} == 0 )) ; then echo "teeu error: need 1 or more arguments" echo "$help" return 1 fi - local file="$1"; shift - local MAPFILE - mapfile -t - for line in "${@:-$MAPFILE[@]}"; do + (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t + for line in "${MAPFILE[@]}"; do grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" done return 0