I am using bash to prompt a user for a choice using: where a "y" response opens a menu with available panels that can be used.
while true; do
read -p "Do you want to get coverage of a specific panel?" yn
case $yn in
[Yy]* ) menu; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
My question is normally I would use a loop to apply the user selected panel to. However, in this case I can not do that because, there might be 5 files in the directory, but only 1 of those files gets the user selected panel applied to it, the other 4 do not.
For example, say the user selects panel1 and in the directory located at (/user/file/data) that panel1 can be applied to is file1 and file2 . How do I allow the user to select which file in the directory to apply panel1 to? Thank you :).
while true; do
read -p "Do you want to get coverage of a specific panel?" yn
case $yn in
[Yy]* ) menu; select file1 in $(cd /user/file/data;ls);do break;done
echo $file1
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
The user prompt is executed and if "y" is entered then the menu function is called.
while true; do
read -p "Do you want to get coverage of a specific panel?" yn
case $yn in
[Yy]* ) menu; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
menu() {
while true
do
printf "\n please make a selection from the MENU \n
==================================
\t 1 Incidental Findings
==================================\n\n"
printf "\t Your choice: "; read menu_choice
case "$menu_choice" in
1) incidental ;; select file1 in $(cd /user/file/data;ls);do break;done
......... (whatever command to execute)
*) printf "\n Invalid choice."; sleep 2 ;;
esac
done
}
So if the "incidental" is selected after the ;; is where to add select file1 in $(cd /user/file/data;ls);do break;done ? Thank you