July 15, 2012
Pick random line from text file with bash and shuf.

So lets say you have a text file called list.txt with entries like: What if you wanted to pick a random entry? The easiest solution is to use the ‘shuf’ tool, which is standard on CentOS as part of coreutils. The output would be a random line from our file!