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 exists
clear
echo -n "Enter user to check: "
read $uzer
grep -c '^${uzer}:' /etc/passwd
if [ $? -eq 0 ]; then
echo "User does exist :)"
else
echo "No such user"
fi
In terminal the following works fine:
grep -c '^devuser1:' /etc/passwd
RETURNS: 1
grep -c '^devuser1234:' /etc/passwd
RETURNS: 0
I've tried many combinations of passing the read variable into '^${uzer}:'
with no joy. Any ideas what else I can try?
read $uzer
should beread uzer