Question
Write a function in UNIX that will take a filename as input. If the file exist, it will display the content of the file. Next
Write a function in UNIX that will take a filename as input.
If the file exist, it will display the content of the file. Next use the case structure to display a command menu, and prompt the user for selection. Depending on the users selection, the user is allowed to write, append, edit the file, or exit the menu. In case the users selection is invalid, prompt the user no valid selection is made.
If the file doesnt exist it will open the file in vi or vim. So you can write in the file and save it.
COMMAND MENU
Enter 1 to write to file (Using cat)
Enter 2 to append to file (Using cat)
Enter 3 to edit file (Open vi or vim)
Enter 4 to exit menu (Display ByeBye and exit from program)
Example 1
Enter a filename.
cocolor
Displaying the file:
red blue yellow green pink purple indigo orange black white
COMMAND MENU
Enter 1 to write to file
Enter 2 to append to file
Enter 3 to edit file
Enter 4 to exit menu
Enter an option:
4
BYE BYE
Example 2
Enter a filename.
newFile
Creating a new file called newFile :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started