Creating unique users accounts using count.
I am trying to create users accounts reading from a file. I can get it to show if the user already exists but I want it to instead of not creating the user account to create e.g. Scott1 etc.
The code i have so far is : #!/bin/bash while read line do grep -c $line /etc/passwd useradd -m $line done <"users.txt" Thanks for your help. |
Have you had a look at the 'newusers' command? It sounds like you're doing something rather similar :)
No point re-inventing the wheel... unless you've got a fascination with the way the wheel works. Hope this helps, |
Will the 'new user' command will make sure each username is unique. I there are some duplicates within the file and I dont want to remove them I want to make two accounts with the name but add a number on the end of the username. My idea was to use a count but not sure how to implement.
Thanks for replying |
It would seem you could just put a simple 'if' within your while to test your grep.
|
Quote:
Something like this? Code:
#!/bin/bash Cheers, Tink |
All times are GMT -5. The time now is 03:37 AM. |