Say I have the following file:A 1B 2CC 33And I want to create a file containing every combination of two from the previous file, like this:AA 11AB 12ACC 133BA 21BB 22BCC 233CCA 331CCB 332CCCC 3333Can this be done with bash, for an arbitrary file? Each entry can consist of any characters except for newline and space. UTF-8 characters will be included in some entries.I don't care about order.
Create a file of pairs from pairs
shell script;text processing
You can try this with awk reading file twice:awk 'NR == FNR { m[$1] = $2; next; } { for (i in m) { print $1 i, $2 m[i]; } }' file file