storing output from echo & cut into variable

Hi All,

Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found.

I am reading in lines with the following

10001:01234393923:0123447834834:01234482742:NNN:

The number of fields may differ between 3 and 17

I need to store the output from the following echo statements to a variable, but cannot seem to do it. When I execute this is works fine, I used echo to allow me to view each line that is being read in from a file I previously created.

    echo $EachLine |cut -d":" -f1
    echo $EachLine |cut -d":" -f\`expr $COUNTER \+ 1\`

Here is the code in context.

while read EachLine
do
COUNTER=1
while [ $COUNTER -le $NOPHONES ]
do
echo $EachLine
PHONEPOS=$COUNTER
echo $EachLine |cut -d":" -f1
echo $EachLine |cut -d":" -f`expr $COUNTER + 1`
COUNTER=`expr $COUNTER + 1`
# Output variables below in different order to file2.
#
# End of output to file2
done
done < file1.$$

Thanks in advance for any assistance.
Nigel...

---------- Post updated at 09:47 AM ---------- Previous update was at 09:27 AM ----------

I have managed to get one all but one of the statments working now. using

    STRRECNO="\`echo "$EachLine" |cut -d":" -f1\`"

However the following line does not work I think still due to the `` but I

    STRPHONENUM="\`echo "$EachLine" |cut -d":" -f\`expr $COUNTER \+ 1\`\`"

Thanks for any help

Nigel...

 
STRPHONENUM=$(echo "$EachLine" |cut -d":" -f`expr $COUNTER + 1`)