Mass setting user passwords

Every need to change (or set) passwords for a large number of users? Something like this code snippet may help.

# find all the usernames with bash logins
usernames=$(cat /etc/passwd  | grep bash | sed 's/:.*//g)
for i in $usernames; do
    echo "somepassword" | passwd --stdin $i
done