このスクリプトを書くのに役立ちますか? Bashでスクリプトを書く方法を学んでいます。うまくいきますが、何とかうまくいきません。
#!/bin/bash
echo "Please enter your name: "
read name
if ["$name"="Marek"]
then
echo -e "Hello Marek!\n"
else
echo "Sorry not you"
fi
出力:
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
答え1
この試み:
#!/bin/bash
echo "Please enter your name: "
read name
if [ "$name" = "Marek" ]; then
echo -e "Hello Marek!\n"
else
echo "Sorry not you"
fi