Help with sed Command

I have to rearrange the fields so that the fields are separated by a specific delimiter and come in this order: state, last name, first name, city.

Mickey Mouse, 1111 Disney Dr., Orlando FL
Minnie Mouse, 1112 Disney Dr., Anaheim CA
Adam Voter, 902 Biscayne Blvd., Miami FL
Zelda Bosco, 4000 State St., Chicago IL
Susie Green, 799 15th St., Indianapolis IN
Tom Furter, 800 N. Walsh St., Milwaukee WI
Dave Ile, 111 W. Illinois Ave., Madison WI
Sam Karter, 1400 E. 57th St., Los Angeles CA
Howard Messer, 5957 W. 157th St., Orland Park IL
Ogden Nash, 2800 S. Lake St., Berkeley IL
Penelope Ogden, 1527 W. Aurora Rd., Naperville IL
Harvey Pelican, 800 N. Lake Shore Dr. #134, Michigan City IN
Tawanda Rice, 1027 Belmont Place, West Palm Beach FL
Kendall Smith, 2231 W. 13th St., Madison WI
Byron Trapp, 5 S. Maple Dr., Indianapolis IN
Milton Callahan, 333 Cordoba Rd., Schaumburg IL
Dominique Daniels, 771 W. 77th Ct., Gary IN
Vickie Edison, 14251 W. Central, Milwaukee WI
Gandalf Addison, 200 Palm Drive, Jupiter FL
Gollum Zeller, 908 Martin Pl., Tampa FL
Jenilee Harrison, 511 River Rd., San Francisco CA
Waylon Jetson, 111 Skyway Dr., Green Bay WI

But it have to look like this...

FL:Mouse:Mickey:Orlando
CA:Mouse:Minnie:Anaheim
FL:Voter:Adam:Miami
IL:Bosco:Zelda:Chicago
IN:Green:Susie:Indianapolis
WI:Furter:Tom:Milwaukee
WI:Ile:Dave:Madison
CA:Karter:Sam:Los Angeles
IL:Messer:Howard:Orland Park
IL:Nash:Ogden:Berkeley
IL:Ogden:Penelope:Naperville
IN:Pelican:Harvey:Michigan City
FL:Rice:Tawanda:West Palm Beach
WI:Smith:Kendall:Madison
IN:Trapp:Byron:Indianapolis
IL:Callahan:Milton:Schaumburg
IN:Daniels:Dominique:Gary
WI:Edison:Vickie:Milwaukee
FL:Addison:Gandalf:Jupiter
FL:Zeller:Gollum:Tampa
CA:Harrison:Jenilee:San Francisco
WI:Jetson:Waylon:Green Bay 

I'm using Unix/Linux for the first time and i'm really having problems can you help me. Thank You

Hi, what have you tried so far? Can you show us where you are having problems?

This is what I have so far....

cat customer. txt  |
sed - e 's/\([ ^]) 

And I believe I'm off to a bad start with that

---------- Post updated at 04:13 AM ---------- Previous update was at 03:01 AM ----------

cat customer.txt | sed 's/^\(.*\) \([A-Z][A-Z]\)$/\2:\1/'

So worked on a little bit more still needs help

I Really appreciate the help everyone. I was able to use some of your responses and get the text file to work currently and I actually understand your responses than what the professor was trying to tell me. Thank You once again

Professor? This should probably have been in the homework forum.

Seems a "classmate" has showed up with the same data.

Regards,
Alister

1 Like