I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far:
#! /bin/bash
if [[ $@ == "username" ]]
then
echo "Hello, $@!"
echo "The current directory is $PWD"
echo "The home directory is $HOME"
else
echo "Hello Stranger"
fi
echo "Would you like to:"
echo "1) See your name"
echo "2) See your current directory"
echo "3) See your home directory"
echo "4) Quit"
read case;
case $case in
1) echo "username";;
2) echo "$PWD";;
3) echo "$HOME";;
4) echo "Quit";;
esac
rep="$case"
#THIS IS WHAT I DONT GET: it just runs this command like 5 times but does not let me choose a option
while (( $rep <=1 ))
do
echo "Would you like to:"
echo "1) See your name"
echo "2) See your current directory"
echo "3) See your home directory"
echo "4) Quit"
rep=$(( rep+1))
done
I really need help figuring this out