parsing - Adding users from CSV in Linux using BASH -
My CSV file contains the necessary information like this first name, last name, user-side. I have 5 users who will have to parse me with CSV I have hit a wall to create an account assigned to a group (Group 1) and assign an encrypted temporary password, any help would be awesome Thank you!
#! / Bin / bash OLDIFS = $ IFS IFS = "," when first read lastname userid useradd -c "$ firstname $ lastname -d / home / $ userid -G group 1 -s / bin / bash $ userid" done IFS = $ OLDIFS Adding any user to script execution.
It should help you.
#! / Bin / bash OLDIFS = $ IFS IFS = "," The first name is read lastname userid Useradd -c "$ {first name} $ {lastname}" -d / home / "$ {userid}" -G group 1 -s / bin / bash "$ {userid}" & lt; File.csv Your script is okay, I've made some changes as below
- The variable is cited, it will prevent the unwanted extension. It is not necessary to reset
-
IFSbecause the script runs in a subseal. -
Whilerequires a file input, it has been added.
Comments
Post a Comment