Convert text to columns

Hi.
I need an input file of a single word pr. line converted in into a list of random pairs.

i need input like this

word1
word2
word3
word4

to be outputted like this:

word3 word1
word2 word4

My attempt is a tedious while loop like this:

nfiles=$(cat inputfile | wc -l)       #'wc -l inputfile' outputs name of file. this is unwanted. 
while [[ $nfiles -gt 0 ]]; do
    field1=$(shuf -n 1 inputfile)
    sed -i /$field1/d inputfile
    field2=$(shuf -n 1 inputfile)
    sed -i /$field2/d inputfile 
    echo "$field1 $field2" >> outputfile 
    nfiles=$(cat inputfile | wc -l)
done

Any help much appreciated. Thanks

Since you have shuf,

shuf inputfile > /tmp/$$
paste inputfile /tmp/$$ > outputfile
rm -f /tmp/$$
1 Like

Try also

shuf inputfile | paste -sd"\t\n"
word4    word1
word3    word2
2 Likes

Thank you. I wasn't aware of paste..

shuf inputfile | paste - -
1 Like