Monday, 23 November 2015

Joining fields and removing delimiter

This is how to create usernames from the attendance list. It is highly unlikely to be the most efficient way, but its quick and I understand it.

  1. Copy the names and surnames from the spreadsheet and paste into a text editor. Save as for example names.
  2. Convert to lowercase. Names will be in two columns: firstname and surname:
    dd if=names of=lowercase conv=lcase
  3. Create a file for each column, then get just the surname initial (I don't care about the inefficiency of creating all these files instead of cooking up a fancy one-liner)
    cut -f1 lowercase > first
    cut -f2 lowercase > last
    cut -c1 last > lastinitial
  4. Join it back up and remove the delimiter:
    paste -d : first lastinitial > fplus1
    cat fplus1 | tr -d : > usernames
Now you have a file of usernames of first names + 1 initial, in lower case. Fix by hand for unusual names with brackets or spaces.