removing a delimiter at the start of row

I Have this code

while [ ${iCount1} -le ${reccount} ]

do

column1=":`cat /home/test_inter.txt|head -${iCount1}|tail -1|cut -d "," -f2`"

columnA=$columnA$column1

iCount1=`expr ${iCount1} + 1`

done

echo $columnA

The output of this code is coming as

:1:2:2:3:3:4

A colon(:slight_smile: at the beginning of each row I am using this colon as a field delimiter. But I don't want it at the beginning of each row.

Any help regarding this?

Not a very efficient solution:

echo ":1:2:2:3:3:4" |  cut -c 2-

Get everything from second character onwards

The reason is, that you preceed EACH field with a colon in the "column1=...." line. Since you do this in a loop anyways (i'm pretty sure you could achieve this more easily, but that only as a aside) start without the colon and only add the colon from field 2 onwards. Oh, by the way: backticks are OUT and "expr" is unnecessary in ksh:

column1="$(cat /home/test_inter.txt|head -1|tail -1|cut -d "," -f2)"
iCount=2
while [ ${iCount1} -le ${reccount} ] ; do

     column1="${column1}:$( cat /home/test_inter.txt |\
                            head -${iCount1} |\
                            tail -1 |\
                            cut -d "," -f2 \
                          )"


     (( iCount1++ ))

done

echo $column1

bakunin