2. Write a bash script that (1) prompts the user to enter a Linux command and re
ID: 3756080 • Letter: 2
Question
2. Write a bash script that (1) prompts the user to enter a Linux command and reads in the user's input, (2) prints out a meaningful message with the user's entered command to be executed, and finally (3) executes the user's entered command. The Linux command is to be read in, not passed as a command-line argument. This bash script should be called rec04B.sh. SAMPLE OUTPUT (input in bold green): ./ Enter Linux command to perform: ls Command to be executed: 1s a.out Lab01A. Lab02B.sh minorl.c minor2.c rec04B. shExplanation / Answer
The answer to your quation would be this bash script ,I have added comments (in the form of # so that it is readable):
echo "Enter the linux command to perform:" #asks for input
read varname #read input
echo Command to be executed: $varname
echo Output:
$varname #execute the input
Hope this helps :).
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.