1752785 Members
6052 Online
108789 Solutions
New Discussion юеВ

SED

 
Matt Dunfee
Occasional Contributor

SED

I have a file that looks similar to the following:
server1_138476245,
server2_543989432,
server3_534242389,

Is there any way to manipulate this file to remove the ",". I suspect the 'sed' command could be used, but unfortunately I'm not too familiar with this utility.

Any help would be greatly appreciated.

Thanks!
-Matt
3 REPLIES 3
S.K. Chan
Honored Contributor

Re: SED

You can do ..

# cat | sed 's/,//g' >
S.K. Chan
Honored Contributor

Re: SED

or ..

# cat | tr "," "\000" >

The \000 is the null character.
Wodisch
Honored Contributor

Re: SED

Hello Matt,

if you would like to get rid of ALL commas, then it is enough to

tr -d "," < org-file > new-file

But if you only want to get rid of the trailing commas, you'll need something like

sed 's/,$//' < old-file > new-file

Just my $0.02,
Wodisch