From 66b2b2612732e6782f5ed598361e0cc7ee061e7e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 20 Nov 2016 13:51:18 +1300 Subject: Add ddup(1df) --- .gitignore | 1 + Makefile | 6 ++++-- README.markdown | 1 + bin/ddup.awk | 2 ++ foo | 4 ++++ man/man1/ddup.1df | 20 ++++++++++++++++++++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 bin/ddup.awk create mode 100644 foo create mode 100644 man/man1/ddup.1df diff --git a/.gitignore b/.gitignore index 4e941ee3..97c59ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +bin/ddup bin/han bin/mean bin/med diff --git a/Makefile b/Makefile index 7e00910b..2ac5804e 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,8 @@ EMAIL := tom@sanctum.geek.nz KEY := 0xC14286EA77BB8872 SENDMAIL := msmtp -all : bin/han \ +all : bin/ddup \ + bin/han \ bin/mean \ bin/med \ bin/mftl \ @@ -83,6 +84,7 @@ all : bin/han \ clean distclean : rm -f \ + bin/ddup \ bin/han \ bin/mean \ bin/med \ @@ -181,7 +183,7 @@ install-bash-completion : install-bash install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d -install-bin : bin/han bin/mean bin/med bin/mftl bin/mode bin/rfct \ +install-bin : bin/ddup bin/han bin/mean bin/med bin/mftl bin/mode bin/rfct \ bin/rndi bin/sd2u bin/slsf bin/su2d bin/tot bin/unf install-bin-man install -m 0755 -d -- "$(HOME)"/.local/bin for name in bin/* ; do \ diff --git a/README.markdown b/README.markdown index 13b6737e..1dd1643c 100644 --- a/README.markdown +++ b/README.markdown @@ -417,6 +417,7 @@ Installed by the `install-bin` target: * `clrd(1df)` sets up a per-line file read, clearing the screen first. * `clwr(1df)` sets up a per-line file write, clearing the screen before each line +* `ddup(1df)` removes duplicate lines from unsorted input. * `dmp(1df)` copies a pass(1) entry selected by `dmenu(1)` to the X CLIPBOARD. * `dub(1df)` lists the biggest entries in a directory. diff --git a/bin/ddup.awk b/bin/ddup.awk new file mode 100644 index 00000000..28b4d135 --- /dev/null +++ b/bin/ddup.awk @@ -0,0 +1,2 @@ +#!/usr/bin/awk -f +!seen[$0]++ diff --git a/foo b/foo new file mode 100644 index 00000000..d68dd403 --- /dev/null +++ b/foo @@ -0,0 +1,4 @@ +a +b +c +d diff --git a/man/man1/ddup.1df b/man/man1/ddup.1df new file mode 100644 index 00000000..ca5e35a0 --- /dev/null +++ b/man/man1/ddup.1df @@ -0,0 +1,20 @@ +.TH DDUP 1df "November 2016" "Manual page for ddup" +.SH NAME +.B ddup +\- remove duplicates from unsorted output +.SH USAGE +.B ddup +FILE1 [FILE2 ...] +.br +.B ddup +< FILE +.br +program | +.B ddup +.SH DESCRIPTION +.B ddup +removes duplicate lines from the input without requiring it to be sorted. +Because it caches each unique line, this is less efficient than using sort(1) +and then uniq(1), but necessary if maintaining the order is desirable. +.SH AUTHOR +Tom Ryder -- cgit v1.2.3