Removing character from list line (at the end)

Hi,

I have file as shown below.

abc,
def,
abc,
xyz,

I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that?

  • Malay
sed '$s/,$//' filename

Thanks a lot.

Its working.

  • Malay