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