Samson
Samson

Reputation: 75

Remove Name Suffix in a file using Sed in linux

I have one csv file including name information with suffix.

LNAME,Date
MURRY-IV,1990
SMITH,1998
DEL-IVY,2000
EDWARD-IV,1990

I want to remove all those suffix parts. My expected output should be

LNAME,Date
MURRY,1990
SMITH,1998
DEL-IVY,2000
EDWARD,1990

To do that, I used sed 's/-IV//g' filename. But the output became

LNAME,Date
MURRY,1990
SMITH,1998
DELY,2000
EDWARD,1990

So the name DEL-IVY was revised as well. How shall I get around this issue?

Upvotes: 0

Views: 167

Answers (1)

KamilCuk
KamilCuk

Reputation: 141020

Match -IV followed by a comma....

sed 's/-IV,/,/'

Upvotes: 1

Related Questions