I'm having trouble parsing through a csv file to add users.I wrote a small script to add a list of 1000 users:export IFS=,cat users.csv | while read a b c d e f g; do useradd -d -u $a -U $d ; doneThe CSV file is formatted as:ps2946,male,Phil Harris,Recording,6508 Hollywood Blvd,Nov 16 1950,760 901 3537mc3225,male,Mel Blanc,Radio,6385 Hollywood Blvd.,Oct 1 1983,626 647 5560fn1029,male,Franklin Pangborn,Motion pictures,1500 Vine Street,Mar 10 1911,858 497 6108we9602,undefined,Webb Pierce,Recording,1600 Vine Street,Sep 3 1988,559 595 6063However upon running the script it iterates through the entire file repeating :useradd: invalid home directory '-u'I used export IFS to seperate the words by comma and use them as the parameters for the useradd command. I read the manual and used the value for the home directory but I feel like my entire script is off.Can someone please help me in properly formatting a script to add users from a CSV file?For reference I used this thread as a base: https://stackoverflow.com/questions/4439536/shell-script-to-parse-through-a-file-csv-and-process-line-by-line
Parsing through a CSV file to add users
ubuntu;csv;useradd