I want to grep the users (first column) from the /etc/passwd file and assign them a password. I only want to do this for user accounts and not default system accounts. So far I have a simple bash script
#!/bin/bash
touch /usertempfile
grep "/home" /etc/passwd |grep -v "/bin/false"|grep -v "/sbin/nologin"|grep -v $USER |awk -F":" '{print $1}' >> /userstempfile
for i in $(cat /usertempfile); do
echo -e "password/npassword" |passwd $i
done
rm -rf /usertempfile
The script is able to extract the users from the /etc/passwd file that are not a default system account but is unable to change the passwords of the users which are in that file. What am I doing incorrectly?
echo -e "password/npassword"
in your script and not\n
?