Skip to content

Instantly share code, notes, and snippets.

@kvpb
Last active July 28, 2022 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvpb/c43da7dfa18d8873f4469e884da86100 to your computer and use it in GitHub Desktop.
Save kvpb/c43da7dfa18d8873f4469e884da86100 to your computer and use it in GitHub Desktop.
Test Script 73: BASH pairwise comparison without duplicates
#!/usr/bin/env bash
var=( {0..9} ); #var=( $({0..$[RANDOM%+9]}) );
printf "Set: {$(var2=$(printf ", %s" "${var[@]}") && var2=${var2:2} && printf "${var2}\n";)}"'\n'"Pairs: "'\n';
for (( i = 0; i < ${#var[@]}; i++ ));
do
for (( j = i + 1; j < ${#var[@]}; j++ ));
do
# printf "(${i}, ${j}): "'%d\n'; #printf "(${!var[${i}]}, ${!var[${j}]}): "'%d\n'; # array element nummbers
printf "(${var[${i}]}, ${var[${j}]})"'\n'; # array elements
done;
done;
# script73.sh
# Test Script 73: BASH pairwise comparison without duplicates
#
# Author: Karl V. P. Bertin `kvpb`
# Telephone: +33 A BB BB BB BB
# Email: local-part@domain
# LinkedIn: https://www.linkedin.com/in/karlbertin
# Facebook: https://www.facebook.com/profile.php?id=
# Instagram: https://www.instagram.com/karlbertin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment