Adding a comma at the end

Hallo Team,

I have a big file and the sample looks like below:

0105550
0105550
0105550
0105550
0105550
0125550
0125550
0125550
0125550
0125550
0215650
0215650
0215650
0215650
0215650
0315550
0315550
0315550
0315550
0315550
0335550
0335550
0335550
0335550
0335550
040555
040555
040555
040555
040555

I would like to add a comma at the end of each like like below:

0105550,
0105550,
0105550,
0105550,
0125550,
0125550,
0125550,
0125550,
0125550,
0215650,
0215650,
0215650,
0215650,
0215650,
0315550,
0315550,
0315550,
0315550,
0315550,
0335550,
0335550,
0335550,
0335550,
0335550,

How can i achieve this?

Reagrds,

What have you tried?

1 Like

Nevermind Team. I am all good.

Hello,

Not sure if you have tried similar to same or not, but following may help you.

 awk -vs1="," '{print $0 s1}' file_name

Output will be as follows.

0105550,
0105550,
0105550,
0105550,
0105550,
0125550,
0125550,
0125550,
0125550,
0125550,
0215650,
0215650,
0215650,
0215650,
0215650,
0315550,
0315550,
0315550,
0315550,
0315550,
0335550,
0335550,
0335550,
0335550,
0335550,
040555,
040555,
040555,
040555,
040555,

2nd way:

 sed 's/$/\,/g'  file_name

3rd way:

awk 'gsub(/$/,",") 1' file_name

Output will be the same.

Thanks,
R. Singh