Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Automatic Zoom Actual Size Page Fit Page Width 50% 75% 100% 125% 150% 200% 300% 400% CS 140U Win 2018 Assignment 5: Bash Programming I

Automatic Zoom Actual Size Page Fit Page Width 50% 75% 100% 125% 150% 200% 300% 400%

CS 140U Win 2018

Assignment 5: Bash Programming I

Due: Wednesday, Mar 7 at 11:59pm

Write a bash script file that when run will take the first argument given and determine if it

exists in the current directory. If it does, it should determine if it is a file or directory. If it is a

file, it will display only the last 4 lines to the terminal in sorted order (just sort the last 4 lines).

If it is a directory, it should display the contents of that directory (the files and subdirectories).

Before doing anything, it should check to see if the user typed in an argument; if not it should

print a message and quit.

NOTE: You can also write the script to prompt the user for the filename using

read

command (see chapter 10). I

n this case, you can ignore any given arguments.

=====================================

EXAMPLE RUNS (This is just an example. The file names will be different when I grade your

script)

NOTE: The first three command lines are just for information. Also, when grading, I will be

using a directory with a different content than the one shown below.

=====================================

~$

ls

adir afile.dat assg5.sh names1.txt

~$

ls adir

afileinadir.txt subdirofadir

~$

cat names1.txt

Andy

Frank

Anne

Margaret

Maria

Arthur

Nancy

Jane

Kathy

Mark

Cathy

Zachary

Barney

~$

./assg5.sh

Need to enter a name

~$

./assg5.sh nothere

This name doesn't exists

~$

./assg5.sh names1.txt

name exists

This is a file

Barney

Cathy

Mark

Zachary

~$

What To Hand In

In your bash script put in a comment with Assignment 5 and your name at

the top. Your bash script should be a text file as I'm going to run it from

command line.

Please make sure it has a .sh ending so I can my grading

script can detect that it is a script.

Again, please no word doc, docx, rar, zip, rtf files; these won't run from the

command line.

This file needs to be submitted to d2l before the above due date/time in order to

be considered on time. If you submit any new files after the due date/time, the

entire assignment is considered late (even if earlier files were submitted on

time). Remember to check that your submissions are present in your

assignments folder and that they are the correct files.

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago