vendredi 22 novembre 2019

Why doesnt my while loop works Im trying to write a bash script which loop as long as i didnt take the fouth choice

Here is my code every time i press 1,2 or 3 so i get out its excute but the out i get done! forever loop what do i did wrong ?

echo "Wrhat is your name ! :"

read Name

echo "Hello $Name ! What would you like me to do ?"

echo "Preas 1 to create a note !"

echo "Preas 2 to write a text and save it in a note?"

echo "Preas 3 to copy your new note ?"

echo "Preas 4 to exit ?"

echo $Name >> Note.txt

read Num

while [[ "$Num" != "" ]] ; do

if [[ $Num = "1" ]]; then

echo > Note.txt

echo "Done!"

elif [[ $Num = "2" ]]; then

echo "Write your text : "

read text

echo $text >> Note.txt

echo "Done!"

elif [[ $Num = "3" ]]; then

cp Note.txt Note1.txt

else exit 0

fi

done

Aucun commentaire:

Enregistrer un commentaire