From 8b398553a6d6667c004b5fd2125501613471a2b5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 28 May 2017 12:56:15 +1200 Subject: Add mw(1df) --- .gitignore | 1 + Makefile | 1 + README.markdown | 2 ++ bin/mw.awk | 10 ++++++++++ man/man1/mw.1df | 25 +++++++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 bin/mw.awk create mode 100644 man/man1/mw.1df diff --git a/.gitignore b/.gitignore index e2f5a857..4d9ef923 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ bin/mktd bin/mode bin/motd bin/murl +bin/mw bin/nlbr bin/onl bin/osc diff --git a/Makefile b/Makefile index 1f620612..d570e6b8 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,7 @@ BINS = bin/ap \ bin/mode \ bin/motd \ bin/murl \ + bin/mw \ bin/nlbr \ bin/onl \ bin/osc \ diff --git a/README.markdown b/README.markdown index 9d16abe5..6b0ff38e 100644 --- a/README.markdown +++ b/README.markdown @@ -502,6 +502,8 @@ Installed by the `install-bin` target: * `mkcp(1df)` creates a directory and copies preceding arguments into it. * `mkmv(1df)` creates a directory and moves preceding arguments into it. * `motd(1df)` shows the system MOTD. +* `mw(1df)` prints alphabetic space-delimited words from the input one per + line. * `onl(1df)` crunches input down to one printable line. * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s `s_client` subcommand. diff --git a/bin/mw.awk b/bin/mw.awk new file mode 100644 index 00000000..f51b8272 --- /dev/null +++ b/bin/mw.awk @@ -0,0 +1,10 @@ +# Crude approach to get alphabetic words one per line from input, not sorted or +# deduplicated +BEGIN { + RS = "(--|['_-]?[^[:alnum:]'_-]+['_-]?)" +} +{ + for (i = 1; i <= NF; i++) + if ($i ~ /[[:alpha:]]/) + print $i +} diff --git a/man/man1/mw.1df b/man/man1/mw.1df new file mode 100644 index 00000000..51623600 --- /dev/null +++ b/man/man1/mw.1df @@ -0,0 +1,25 @@ +.TH MW 1df "May 2017" "Manual page for mw" +.SH NAME +.B mw +\- get space-delimited alphabetic words from input, one per line +.SH SYNOPSIS +.B mw FILE1 +[FILE2...] +.br +prog1 | +.B mw +.SH DESCRIPTION +.B mw +separates the input into space-delimited words and prints them one per line, +with no deduplication or sorting. It's a fairly naïve approach to the problem +but it works fine as a crude initial approach. +.SH NOTES +This was written after watching that lovely old AT&T video where members of the +Unix team (specifically Brian Kernighan and Lorinda Cherry) demonstrate piping +programs together; Kernighan demonstrates `makewords` during his example. +.P + +.SH SEE ALSO +ddup(1df), sort(1), uniq(1) +.SH AUTHOR +Tom Ryder -- cgit v1.2.3