diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-01 13:27:22 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-01 13:28:26 +1200 |
commit | 9666a2fa7bf21db5ad2ed28444cd8db18012cdc7 (patch) | |
tree | 9173c5425c526ff3396335ae6ebc998d235e4873 /bin/rndl | |
parent | Change coffee joke to FSF/SPI/OBSD donate request (diff) | |
download | dotfiles-9666a2fa7bf21db5ad2ed28444cd8db18012cdc7.tar.gz dotfiles-9666a2fa7bf21db5ad2ed28444cd8db18012cdc7.zip |
Add rndl(1)
Diffstat (limited to 'bin/rndl')
-rwxr-xr-x | bin/rndl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/bin/rndl b/bin/rndl new file mode 100755 index 00000000..17118862 --- /dev/null +++ b/bin/rndl @@ -0,0 +1,9 @@ +#!/bin/sh +# Print a random line from argument files +if [ "$#" -eq 0 ] ; then + printf >&2 'rndl: Need at least one filename\n' + exit 1 +fi +lc=$(sed '$=;d' "$@") || exit +ri=$(rndi 1 "$lc") || exit +exec sed -- "$ri"'!d' "$@" |