X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=teeu-function;h=91d3e40e605d9aab2d9b4e356e4a6078d76369b8;hb=ea655d17a5e11dd740574d0a1d5ca2401d5cf063;hp=e4705b7afd3e07a3803602cdd9aad9deec0295e1;hpb=a468c8cdb5a12fce2487ae9816cdb4501ffffa09;p=tee-unique diff --git a/teeu-function b/teeu-function index e4705b7..91d3e40 100644 --- a/teeu-function +++ b/teeu-function @@ -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