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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swap Firstname / Surname in GEDCOM file

Status
Not open for further replies.

Celsoft

Programmer
Aug 27, 2008
17
IE
Hi - I've gone a bit rusty so .....

I have a GEDCOM file (used in genealogical circles) containing lines with names in the format

1 NAME Surname /Firstname/

as well as lots of other linetypes. The Firstname on input is enclosed in forward-slashes.

I want to use gawk to edit these lines (i.e. lines starting with "1 NAME ") and swap the Surname and Firstname in each case. The forward-slashes should remain in the same position on output i.e. enclosing the Surname..... giving

1 NAME Firstname /Surname/

Other lines should be output without change.

Any help appreciated.
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Great!

I was about to suggest :

sed 's/^1 NAME \([[:print:]]*\) \/\(.*\)\//1 NAME \2 \/\1\//g' gedcom.txt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top