I have 2 text files, users.txt with a list of 1000 users and groups.txt with a list of 50 groups. I want to run a command that adds 30 users to each group (ex: users 1-30 to group 1, users 31-60 to group 2, etc.). What would be the most practical way of doing this?
I suppose I could create 50 new text files with a list of 30 users on each and run 50 bash scripts, but I feel there is a better way than this.
Edit: This is what I have so far:
for i in `cat users.txt` ; do useradd $i; echo Pass$i | passwd $i -- stdin; done for i in `cat groups.txt ; do groupadd $i; done