Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a comma at the end of a line

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
I have numerical data in a file

12345678901,

How can I remove the , at the end of the line ?

I have tried

sed 's/,/d' filename > filename2
but it returns a file of 0bytes !
 
that's deleting every line where there's a comma....

try something like

sed 's/,$//' filename > filename2

the $ should mean that only commas at the *end* of a line are removed. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Thanks Mike I finally did it by

sed 's/,/ / filename > filename2

Thanks, I have tried your way as well, works both ways, but yours is safer !
 
No problem Max :)

I think you're replacing the comma with a space there, is that what you meant to do? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top