summaryrefslogtreecommitdiffstats
path: root/util/bin/randline
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2011-07-31 02:16:15 +0200
committermakefu <github@syntax-fehler.de>2011-07-31 02:16:15 +0200
commit7f5321696a2d6f3b8292ab3246f2374ba0334725 (patch)
tree79488f6aa7a814e249c3dd7a05c6bb56b8dd7d0c /util/bin/randline
parent074d78ba9de200950f0b64cb8f2b6efae66fa56d (diff)
randline: reimplemented
Diffstat (limited to 'util/bin/randline')
-rwxr-xr-xutil/bin/randline13
1 files changed, 3 insertions, 10 deletions
diff --git a/util/bin/randline b/util/bin/randline
index cd9476e7..75618664 100755
--- a/util/bin/randline
+++ b/util/bin/randline
@@ -1,12 +1,5 @@
#! /bin/sh
-#
-# choose a line randomly.
-#
-set -euf
+# Author: tv,makefu
+# Info: for old version see commit b9924
-lines="`cat`"
-count=`echo "$lines" | wc -l`
-random=`od -An -t u8 -N 8 /dev/urandom`
-choice=`echo "$random % $count + 1" | bc`
-
-echo "$lines" | sed -n "${choice}p"
+cat | shuf | head -n 1