i am prompting for a name to search.
read user
if [ grep "^$user" /etc/passwd ]
then
however, i get this error:
please enter a username on the system:
fool
menu_script2.sh: line 123: [: ^fool: binary operator expected
i am prompting for a name to search.
read user
if [ grep "^$user" /etc/passwd ]
then
however, i get this error:
please enter a username on the system:
fool
menu_script2.sh: line 123: [: ^fool: binary operator expected
Try:
read user
grep "^$user" /etc/passwd > /dev/null 2>&1
if [ $? == "0" ]
then
dont work
grep "^$user" /etc/passwd
alone will print a line from /etc/passwd that matches ^$user. What does that line have to do with logical if test?
You are missing backticks and operator there.
if [ X`grep "^$user" /etc/passwd` != X ] ; then #user found in /etc/passwd
thank you mirni