X-Git-Url: https://iankelling.org/git/?p=tee-unique;a=blobdiff_plain;f=teeu-function;fp=teeu-function;h=0000000000000000000000000000000000000000;hp=91d3e40e605d9aab2d9b4e356e4a6078d76369b8;hb=0a9b742ea262b02479c3b055d2d31df6199fc90f;hpb=ea655d17a5e11dd740574d0a1d5ca2401d5cf063 diff --git a/teeu-function b/teeu-function deleted file mode 100644 index 91d3e40..0000000 --- a/teeu-function +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# Copyright (C) 2014 Ian Kelling -# This program is under GPL v. 3 or later, see - -teeu() { - local help="Usage: appendu [-h|--help] FILE [LINE] - -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" - return 1 - fi - local MAPFILE - (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t - for line in "${MAPFILE[@]}"; do - grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" - done - return 0 -}