parsing - Adding users from CSV in Linux using BASH -
my csv file contains info needed firstname,lastname,userid. have 5 users need parse csv. in order create business relationship assign group(group1) , assign encrypted temporary passwords. i've nail wall, help awesome. thanks!
#!/bin/bash oldifs=$ifs ifs="," while read firstname lastname userid useradd -c "$firstname $lastname -d /home/$userid -g group1 -s /bin/bash $userid" done ifs=$oldifs
no users beingness added script execution.
this should help you.
#!/bin/bash oldifs=$ifs ifs="," while read firstname lastname userid useradd -c "${firstname} ${lastname}" -d /home/"${userid}" -g group1 -s /bin/bash "${userid}" done < file.csv
your script fine, have made few changes below
have quoted variables, prevent unwanted expansions. resettingifs
not necessary script runs in subshell. while
needs file input, added it. bash parsing csv user-accounts
No comments:
Post a Comment