0

Would you be able to help me with this script? I am learning how to create scripts in bash. It should be working but somehow it is not.

#!/bin/bash
echo "Please enter your name: "
read name
if ["$name"="Marek"]
then
echo -e "Hello Marek!\n"
else
echo "Sorry not you"
fi

Output:

mhudak@nelke:~/practice_before_Exam> ./script2.sh
Please enter your name:
Marek
./script2.sh: line 4: [Marek=Marek]: command not found
Sorry not you


SUSE Linux Enterprise Server 11 (i586)
VERSION = 11
PATCHLEVEL = 1
4

1 Answer 1

0

Try this:

#!/bin/bash
echo "Please enter your name: "
read name
if [ "$name" = "Marek" ]; then
    echo -e "Hello Marek!\n"
else
    echo "Sorry not you"
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .