Append Pipes at the end of each line

Hi ,

I have pipe delimited file containing 12 columns having below data in AIX

Input :

A|B|C|D|E|F|G|H|I|J|K|L^M
A1|B1|C1|D1|E1^M
A2|B2|C2^M

So in first row i have 11 pipes which is fine.
In second row I have 4 pipes, so additional 7 pipes should get append
In third row I have 2 pipes, so additional 9 pipes should get append

Output :

A|B|C|D|E|F|G|H|I|J|K|L^M
A1|B1|C1|D1|E1|||||||^M
A2|B2|C2|||||||||^M

Try:

 awk '{printf $1; for (i=2;i<=11;i++) {printf OFS $i} printf "\n"}' FS='|' OFS='|' file

Hi Carlo,

I have updated the above record with ^M character in AIX.

Thanks

AIX doesn't use ^M - that's (probably) because the file has come over from Windows and you have CRLF line terminators.

Unless you actually need the carriage returns then you should probably take them out (tr, sed, dos2unix, or whatever), or it's a source of possible problems whenever you're processing the file.