Bash one liner to randomize lines in file
linux unix system administration
Discovered that the bash shell has a variable called $RANDOM, which outputs a pseudo-random number every time you call it. Sweet! Allowed me to randomize the lines in a file for a process I needed to do, thusly:
for i in
cat unusual.txt; do echo ā$RANDOM $iā; done | sort | sed -r ās/^[0-9]--- //ā > randorder.txt
In other words, put a random number on every line, sort the file, then take off the random numbers. Worked like a charm.