From 0a4212d4fc9fb3be42768c066dc5288f5defca3b Mon Sep 17 00:00:00 2001 From: Zava Date: Tue, 2 Feb 2021 13:57:51 +0800 Subject: [PATCH] + add uniq-lines command --- bin/uniq-lines | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/uniq-lines diff --git a/bin/uniq-lines b/bin/uniq-lines new file mode 100755 index 00000000..6368665e --- /dev/null +++ b/bin/uniq-lines @@ -0,0 +1,19 @@ +#!/bin/bash +# @Function +# print uniq line keep order, no sorting required + +outputUniqLines() { + awk '{ + s[$0]++ + } + + END { + for(v in s) { + if (s[v] == 1) { + print v + } + } + }' +} + +cat "$@" | outputUniqLines