X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=teeu;h=948169dbffdd190d66a2cb502ec0807800ef4012;hb=0a9b742ea262b02479c3b055d2d31df6199fc90f;hp=9ff55ceba8efd696e1c20b3ca5b99be8afd1a35d;hpb=a468c8cdb5a12fce2487ae9816cdb4501ffffa09;p=tee-unique diff --git a/teeu b/teeu index 9ff55ce..948169d 100755 --- a/teeu +++ b/teeu @@ -8,12 +8,12 @@ teeu() { Tee unique. Append each LINE or if none, each stdin line to FILE if it does not exist in FILE. [-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" @@ -21,7 +21,7 @@ Tee unique. Append each LINE or if none, each stdin line to FILE if it does not fi local MAPFILE (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t - for line in "${$MAPFILE[@]}"; do + for line in "${MAPFILE[@]}"; do grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" done return 0