Edit: I realized that this has nothing to do with $() it's just the result of using echo *. So I just need a way to escape with echo.
I'm writing a script that checks what users don't have passwords by comparing /etc/passwd and /etc/shadow.
So far I have:
cat /etc/passwd | while read -r line ; do
user=$(echo $line | cut -d ":" -f 1)
password=$(cat /etc/shadow | grep $user | cut -d ":" -f 2)
echo $password
done
The problem is that when the result of my grep is * for the password field, which is the case for all users without a password, it seems like ls * is performed? For example:
I'm confused as to why this is happening. Can anyone explain what is happening here? The one answer at the bottom of the picture with an encrypted password is the expected behavior. For the entries without a password I was expecting to get back a *.
