TO achieve this i am using two while loops and 4 If else loops
Now in my production the number of columns are 4 and the number records in the input file are 0.2 million (2 lac) and this script is taking more than 3 hrs to run.
awk '
{
if (NF>1)
{
col[$1]=$1
if (col1[$1]=="")
col1[$1]=$2
else
col1[$1]=sprintf("%s:%s",col1[$1],$2)
if (col2[$1]=="")
col2[$1]=$2
else
col2[$1]=sprintf("%s:%s",col2[$1],$2)
}
}
END{
for (i in col)
print i"|"col1"|"col2
}' filename