Click to See Complete Forum and Search --> : Incredibly simply bash script question


kuber
01-26-2002, 10:50 PM
I am new to this, so bear with me... I read throught the NHF and can't get this to work..

#!/bin/sh

echo -n "yes or no?"
read x
if $x = "y"
then
echo "yes"
else
echo "no"
fi

Owell2001
01-27-2002, 09:55 AM
try
if [ $x = "y" ]
instead of
if $x = "y"

[ 27 January 2002: Message edited by: Owell2001 ]

The Kooman
01-27-2002, 11:38 PM
Originally posted by Owell2001:
<STRONG>try
if [ $x = "y" ]
instead of
if $x = "y"

[ 27 January 2002: Message edited by: Owell2001 ]</STRONG>

Also, it would be good if you enclose $x in quotes in case $x is empty:

if [ "$x" = "y" ]
# blah