Created
January 26, 2020 04:08
-
-
Save oppara/d677f3da14bcac4b06e88d067a3fc59a to your computer and use it in GitHub Desktop.
shell script loop pipe while read
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
users() { | |
# user password | |
cat << EOF | |
foo foofoo | |
bar barbar | |
baz bazbaz | |
EOF | |
} | |
create_user() { | |
while read user pw line | |
do | |
echo "create user ${user}" | |
useradd -g devel ${user} | |
echo "umask 002" >> /home/${user}/.bashrc | |
echo ${pw} | passwd --stdin ${user} | |
done | |
} | |
users | create_user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment