Question: Shell Script to Create a new file Write a shell script using nano or vi editor ( eg , nano scriptname.sh ) like below, that

Shell Script to Create a new file
Write a shell script using nano or vi editor (eg, nano scriptname.sh) like below, that
performs the following task:
1. Add the Shebang (#!/bin/bash) as the first line in your script.
2. Reads the name of the file to check for a filename that exists.
3. Check whether the given input is a directory or regular file. vi
4. If the input is a directory and exists, then display the message Directory exists.
5. If the input is a regular file, then display the message It is a regular file, and the file
exists and display the contents of the file.
6. If the given input name in step-1 doesnt exist, then create the new file with the given name in step-1.

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 Programming Questions!