iankelling.org
/
git
/
tee-unique
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ad53fa7
)
fix bug
author
Ian Kelling
<ian@iankelling.org>
Mon, 11 Aug 2014 19:54:40 +0000
(12:54 -0700)
committer
Ian Kelling
<ian@iankelling.org>
Mon, 11 Aug 2014 19:54:40 +0000
(12:54 -0700)
teeu
patch
|
blob
|
history
teeu-function
patch
|
blob
|
history
diff --git
a/teeu
b/teeu
index 5be4b7688b3d14310a79efb5749e643cc3704027..9ff55ceba8efd696e1c20b3ca5b99be8afd1a35d 100755
(executable)
--- a/
teeu
+++ b/
teeu
@@
-8,7
+8,6
@@
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"
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"
if [[ $1 == --help || $1 == -h ]]; then
echo "$help"
@@
-20,11
+19,9
@@
Tee unique. Append each LINE or if none, each stdin line to FILE if it does not
echo "$help"
return 1
fi
echo "$help"
return 1
fi
- local file="$1"; shift
-
local MAPFILE
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
grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line"
done
return 0
diff --git
a/teeu-function
b/teeu-function
index 5845aff2c40cdfe88597fc762b8932ff2b2ef20a..e4705b7afd3e07a3803602cdd9aad9deec0295e1 100644
(file)
--- a/
teeu-function
+++ b/
teeu-function
@@
-8,7
+8,6
@@
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"
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"
if [[ $1 == --help || $1 == -h ]]; then
echo "$help"
@@
-20,11
+19,9
@@
Tee unique. Append each LINE or if none, each stdin line to FILE if it does not
echo "$help"
return 1
fi
echo "$help"
return 1
fi
- local file="$1"; shift
-
local MAPFILE
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
grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line"
done
return 0