shuf: To shuffle the contents of a file

The command shuf can be used to shuffle the lines of a file passed to it as input.
Example if we have a file,temp, with the following contents


We can shuffle the lines of the file randomly using shuf.

We can store the output in a new file using the -o option i.e

The output would be written to file temp1.
We can also create a random series of numbers using shuf, by using passing the options -i.

If we want all the numbers in one line and not in different lines we can add the options "-z"

Follow by Email