I'm having trouble with my nested while loops. My problem is that my inner while loop only executes once but my outer loop is able to continue to repeat. Here's my code:
while [[ "$input" != "exit" && "$input" != "Exit" && "$input" != "EXIT" ]]
do
echo 'Enter "name" to find files by name'
read input
if [[ "$input" = "name" || "$input" = "Name" || "$input" = "NAME" ]]; then
while [[ "$a" != "f" && "$a" != "s" ]]
do
read -p "Want to search inside only the current folder (f) or include subfolders (s)" a
if [ "$a" = "f" ]; then
echo 'f'
elif [ "$a" = "s" ]; then
echo 's'
elif [[ "$a" != "f" && "$a" != "s" ]]; then
echo 'you have entered an invalid option, please try again'
fi
done
fi
done
Here's a sample output:
Enter "name" to find files by name
Enter "size" to find files with a specified size
Enter "date" to find files by date
Enter "string" to find files containing a particular string
Enter "exit" to exit the script.
name
Want to search inside only the current folder (f) or include subfolders (s)t
you have entered an invalid option, please try again
Want to search inside only the current folder (f) or include subfolders (s)s
s
Enter "name" to find files by name
Enter "size" to find files with a specified size
Enter "date" to find files by date
Enter "string" to find files containing a particular string
Enter "exit" to exit the script.
name # right here is where my inner loop failed to run but I don't see why
Enter "name" to find files by name
Enter "size" to find files with a specified size
Enter "date" to find files by date
Enter "string" to find files containing a particular string
Enter "exit" to exit the script.