Attachment of a new command in the MenuProject script, under option 3, to find t
ID: 3681980 • Letter: A
Question
Attachment of a new command in the MenuProject script, under option 3, to find the file testfile2.txt?
#!/bin/bash
PS3='Please enter your choice:'
options=("Option 1 - File Directory?" "Option 2 - Run MyScript?" "Option 3 - ?" "
Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1 - File Directory?")
echo "File Directory Listing"
ls -1
;;
"Option 2 - Run MyScript?")
echo "myscript File Is Being Executed"
sh ./myscript
;;
"Option 3 - ?")
echo "you chose option 3"
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
~
~
~
~
~
~
~
~
~
~
~
Explanation / Answer
#!/bin/bash
PS3='Please enter your choice:'
options=("Option 1 - File Directory?" "Option 2 - Run MyScript?" "Option 3 - ?" "Option 4 - Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1 - File Directory?")
echo "File Directory Listing"
ls -1
;;
"Option 2 - Run MyScript?")
echo "myscript File Is Being Executed"
sh ./myscript
;;
"Option 3 - ?")
echo "you chose to find testfile2.txt"
find . -name 'testfile2.txt'
;;
"Option 4 - Quit")
break
;;
*) echo invalid option;;
esac
done
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.