Skip to content

Instantly share code, notes, and snippets.

@albert-decatur
Created July 9, 2015 23:39
Show Gist options
  • Save albert-decatur/8ce0bc543e1c3874901a to your computer and use it in GitHub Desktop.
Save albert-decatur/8ce0bc543e1c3874901a to your computer and use it in GitHub Desktop.
get names in last, first, suffix order
cat civil.csv |trim | parallel 'last=$(echo {} | grep -oE "[^ ]+$" ); if [[ -n $( echo "$last" | grep -iE "jr|sr|ii+") ]]; then suffix="$last"; name=$( echo {} | sed "s:[^ ]\+$::g;s: \+$::g" ); last=$( echo "$name" | grep -oE "[^ ]+$" ); first=$( echo "$name" | sed "s:[^ ]*$::g" ); else first=$( echo {} | sed "s:[^ ]*$::g" ); fi; echo "$last,$first,$suffix"' | trim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment