Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CPT 180 BashAssignment Directions Using the following guidelines, create a Bash program. 1. You will be using the CPT180Stuff folder from Chapter 8 for this

CPT 180 BashAssignment

Directions

Using the following guidelines, create a Bash program.

1. You will be using the CPT180Stuff folder from Chapter 8 for this assignment.

2. Create a Bash program named workWithFiles3.sh

3. Add three comment lines at the top of the program that contain:

a. Program Name

b. Program Description

c. Programmer's Name (You)

4. Write code that will do the following:

a. Using an if statement, determine if both the dognames.txt file and the catnames.txt file exist. If both files exist, the program should complete steps b e below. If either file does not exist, the program should print out the message "Unable to access one or more files".

b. Print the contents of the dognames.txt file.

c. Print the contents of the catnames.txt file.

d. Add two cat names to the catnames.txt file. You can pick the names. The example output below shows the names Sassy and Lucy added.

e. Print the contents of the catnames.txt file.

5. Submit the workWithFiles3.sh file into the Bash Assignment Submission Folder.

Hints

1. The echo command when used to append to a file adds a newline after the item is appended.

2. When using Cygwin, you can access the Windows drives by using the cygdrive device. For example, if your CPT180Stuff folder is located in the root directory of the E drive, you could access the dognames.txt file from your Bash program by using the path:

/cygdrive/e/cpt180stuff/pets/dogs/dognames.txt

Example Output

image text in transcribed

My files are located in the following respectively:

C:\cpt180Stuff\cpt180Stuff\pets

C:\cpt180Stuff\cpt180Stuff\pets\dogs

C:\cpt180Stuff\cpt180Stuff\pets\dogs\dognames.txt

C:\cpt180Stuff\cpt180Stuff\pets\cats

C:\cpt180Stuff\cpt180Stuff\pets\cats\catnames.txt

I have the PDF that I am supposed to create the code with available upon request.

chuck@DESKTOP-SNI6U89 $ ./workwithfiles3.sh Spot Max Lassie Rover Snoopy Misty Felix Fluffy Kimba Tom Mortimer Tigger Misty Felix Fluffy Kimba Tom Mortimer Tigger Sassy Lucy chuck@DESKTOP-SNI6089 $

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago