Pairing up numbers

Hi,

Im trying to script the following logic but having some difficulties and wonder if you can help. Have tried to use "cut" to cut pairs but doesn't appear to do what i need when there are more than one pair. Also "wc -c" doesn't appear to be so easy to know which characters to strip of at

I have a confile file as follows

#Client|NAME|Username|No_of_Expected_Connections|Instances|Partitioned
JAY|TEST|[JAY]|2|01 02|N|
JAY|TEST2|[JAY]|4|01 02 03 04|Y|
JAY|TEST2|[JAY]|4|01 02 03 04 05 06 07 08|Y|

The logic i want to apply is:

"Check the value for 'Partitioned' in config file. If its Y then get the value of 'Instances' column and pair them up. So if we have following instances "01 02 03 04 05 06" i want to pair "01 02" and "03 04" and "05 06" and do same for the remaining instances

Idea then is that we have log files which would be named based on the above instances. so for pairs "01 02", there would be two log files

logfile01.txt and logfile02.txt
logfile03.txt and logfile04.txt etc"

Please can you help/advice how best to pair these up?

Many Thanks

#!/bin/bash

while IFS="|" read CLIENT NAME USERNAME CONN INST PART
do
        [ "${CLIENT:0:1}" = "#" ] && continue
        [ "$PART" = "Y" ] || continue

        set -- $INST # If INST="01 02 03 04", $1=01, $2=02, $3=03, $4=04
        MIN=$(($# / 2))
        while [ "$#" -gt 0 ]
        do
                echo "logfile$1.txt" "logfile$2.txt" # Pair the first two
                shift 2 # Get rid of the first two, so $1=$3, $2=$4, ...
        done
done < inputfile
$ ./cfgfile.sh

logfile01.txt logfile02.txt
logfile03.txt logfile04.txt
logfile01.txt logfile02.txt
logfile03.txt logfile04.txt
logfile05.txt logfile06.txt
logfile07.txt logfile08.txt

$

Thanks Corona688,

Just so I understand this, what does the following do pls?

        [ "${CLIENT:0:1}" = "#" ] && continue
        [ "$PART" = "Y" ] || continue

&& is a short-form if-then. If the first statement is true, the second is executed. I use it to skip comment lines beginning with #.

|| is a short-form if-not. If the first statement is false, the second is executed. I use it to skip instances which aren't partitioned.