Skip to content
Snippets Groups Projects

moodle2passwd

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by guillaum.chanel

    Convert a moodle participant list in CSV format to a file in the approaximate passwd format needed by the command newusers

    Edited
    moodle2passwd.sh 479 B
    tail -n +2 "$1" | cut -d, -f1-2 | tr -d '"' | tr '[A-Z]' '[a-z]' | iconv -t ASCII//TRANSLIT | sed -e 's/\( \).*\(,\)/\2/' | sed -e 's/ .*//' | tr ',' '.' | sed -e 's/\(.*\)/\1:\1:::temporary student account:\/home\/\1:\/bin\/bash/
    
    # cut header line | get first and last name only | remove csv quotes | put to lower case | remove accents | keep only the first surname if many | keep only the first lastname if many | put a dot between first and last name | create the passwd file
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment