I define a list in bash like this:
list="element1 element_2 my_element_3 element04"
and I want to do a loop where I iterate through all possible pair combinations. In Perl, I would use a while/foreach with a shift on the list like this:
while (my $element1 = shift (@list)) {
foreach my $element2 (@list) {
print "$element1 - $element2\n";
}
}
I don't want the same element in the pair and don't care about the order of the pairs, so if the list is "A B C", the result should be:
A - B
A - C
B - C
How can I do the equivalent in bash?