💾 Archived View for thrig.me › blog › 2023 › 10 › 30 › randline.sh captured on 2024-07-09 at 01:55:16.

View Raw

More Information

⬅️ Previous capture (2023-11-04)

-=-=-=-=-=-=-

#!/bin/ksh
# randline.sh - not very efficient
awk -v line_idx=$(( RANDOM % $(wc -l "$1" | awk '{print $1}') + 1 )) \
    'NR == line_idx {print;exit}' "$1"