diff options
author | tv <tv@also> | 2011-07-31 01:17:28 +0200 |
---|---|---|
committer | tv <tv@also> | 2011-07-31 01:17:28 +0200 |
commit | 074d78ba9de200950f0b64cb8f2b6efae66fa56d (patch) | |
tree | 26ebe76fed2ceedf569042e95953d03bb6a862d3 /util/bin/randline | |
parent | 4376866fcab70eb27d3c07d268bec0fe9bfad6f1 (diff) |
randline: initial commit
Diffstat (limited to 'util/bin/randline')
-rwxr-xr-x | util/bin/randline | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/util/bin/randline b/util/bin/randline new file mode 100755 index 00000000..cd9476e7 --- /dev/null +++ b/util/bin/randline @@ -0,0 +1,12 @@ +#! /bin/sh +# +# choose a line randomly. +# +set -euf + +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" |