Skip to content

Instantly share code, notes, and snippets.

@edwtjo
Last active August 29, 2015 14:13
Show Gist options
  • Save edwtjo/fe4c35fa6b12947d13cb to your computer and use it in GitHub Desktop.
Save edwtjo/fe4c35fa6b12947d13cb to your computer and use it in GitHub Desktop.
Cleanup display names (VCF entries)
#!/bin/awk -f
# Purges and regenerates contact book display names
# Delete current contact display name
!/^N:/
# Generate a new contact display name on the form:
# N:LASTNAME_1;FIRSTNAME_1;..;FIRSTANME_n;LASTNAME_2;..;LASTNAME_m;;;
/^FN:.*/{
n=n+1;
name=substr($0,4);
split(name,narr," ");
name2=narr[length(narr)];
for (i=1; i<=length(narr)-1; i++) name2 = name2";"narr[i]
print "N:"name2";;;";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment