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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!