Originally Posted by
pkumar3
Hi I have a similar problem.
source file is of format
1,a,b,c,d,e,f,g,h
2
3,f,g,h,i,l
4
5,m,n
And the expected Output file
1,a,b,c
1,d,e,f
1,g,h
3,f,g,h
3,i,l
5,m,n
I used this method
awk -F, '$1!=p1{printf "%s,%s,%s,%s\n",$1,$2,$3,$4} $2!=p2{printf "%s,%s,%s,%s\n",$1,$5,$6,$7,$8; p1=$1;p2=$2}'
the no of coloumns in source file is of varriable length and can grow upto 3000.