For this milestone, you will be removing the Option 1 “stub” (i.e., changing the
ID: 3661504 • Letter: F
Question
For this milestone, you will be removing the Option 1 “stub” (i.e., changing the simple text message to a functioning option in the menu). The process of creating a functional menu item includes the following: 1.Modification of the shell script to update the “Option 1 – ?” to the more meaningful “Option 1 – File Directory?” 2.Alteration of the message that displays when Option 1 is chosen. The stub version displaying “You chose Option 1” should be updated to display “File Directory Listing” 3. Attachment of a new command in the MenuProject script, under Option 1, to navigate to and display the file listing of the current directory
#!/bin/bash
PS3='Please enter your choice: '
options=("Option 1 - ?" "Option 2 - ?" "Option 3 - ?" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1 - ?")
echo "you chose option 1"
;;
"Option 2 - ?")
echo "you chose option 2"
;;
"Option 3 - ?")
echo "you chose option 3"
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
Explanation / Answer
echo "menu"
echo "1.Modification of the shell"
echo "2.Alternation of the message"
echo "3.Attachment of a new command"
echo "4.Exit"
echo "enter * invalid number"
echo "enter u r choice"
read s
case $s in
1)dd if=ram of=ravi conv=ucase
;;
2)cat ravi
;;
3)cat ravi | more
;;
4)exit
;;
*)echo "wrong choice"
;;
esac
Explanation:
switch 1 is used to lower case the words that are written i.e in if = ram and save the file in output file i.e of=ravi
switch 2 is used to display the content of output file i.e of=ravi
switch 3 is used if the output file i.e of=ravi is more than a page to display we use break by piping with another command i.e more
Execution:
the ouput can be exected as fallows
save the file with <filename>.sh
chmod +x <filename>.sh
./<filename>.sh
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.