I've tried every possible combination to get this bash script working. It's part of a larger script, and it basically prompts for a username (to check if it exists) and returns the appropriate response:#! /bin/bash# Script to see if User existsclearecho -n Enter user to check: read $uzergrep -c '^${uzer}:' /etc/passwdif [ $? -eq 0 ]; then  echo User does exist :)else  echo No such userfiIn terminal the following works fine:grep -c '^devuser1:' /etc/passwdRETURNS: 1grep -c '^devuser1234:' /etc/passwdRETURNS: 0I've tried many combinations of passing the read variable into '^${uzer}:' with no joy. Any ideas what else I can try?
bash - reading user variable into bash script grep
bash;regular expression;variable
-c means that you want to know the number of times this user is in /etc/passwd, while $? is the exit code. Those are differents, since the number of times is printed on stdout. Use $() for getting stdout into a variableSecond problem: all your variables, like $uzer will not be substituted with their values when in single quotes. Use double quotes.number=$(grep -c ^${uzer}: /etc/passwd)if [ $number -gt 0 ]; then  echo User does exist :)else  echo No such userfi