filename=""
while [[ $filename = "" ]];do
echo "Enter the file name"
read filename
if [[ -f $filename ]];then
echo "$filename exists"
else
echo "File name doesn't exists, so re-enter"
fi
done
with this style of loop, the loop exists when the file name is not present. But i want the loop to continue until the user input the file name. Please suggest what additional command i should include in the above script.
Quick and dirty way of doing it while utilizing the same code you have is simply adding your code inside an infinite loop.
Keep in mind that this will only look within the directory that the program is executed from unless a full path is given.
Use
break
to get out of the loopor shorter