I have
Tom Jones, Nevada
Madonna, New York
Mary Louise Parker, California
Al Roker, New York
and I need
Nevada: Tom Jones
New York: Madonna, Al Roker
California: Mary Louise Parker
I have come up
^(\w+ \w+ \w+), (\w+ )
$2: $1,
For you grep experts you can see that I have set to find names with three words and a comma and then a word of just one word. This will work in finding those but then I will need to adapt for names with two words and states with two words.
I haven’t figured out the and/or function of grep so I am sure I am doing this the hard way and would like to learn.
I also figure I may have to end up with
Nevada: Tom Jones
New York: Madonna
California: Mary Louise Parker
New York: Al Roker
but then I can sort alphabetically and delete the duplicated states.
Any help in my learning is appreciated. :)
Happy Saturday!
Cindy in (snowy) Indy