Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now that you have the Korn Shell (ksh) installed and have learned more about the language itself, it is time to do some programming: Write

Now that you have the Korn Shell (ksh) installed and have learned more about the language itself, it is time to do some programming:

Write a Korn shell script (and show the code for it here) that accepts exactly 1 command line argument that must be a positive integer. The script will print a comma separated list of integers, all on the same line, starting with the initial command line value and decreasing it by one-to-one. The last printed value must not be followed by a comma. Do not write this script to be executed interactively.

The script must be to handle the following error situations:

Incorrect number of arguments and

Non-positive arguments.

The script file name must be: printnum.sh

The script permissions must be 705 (show in your Word document).

Sample Output (provide yours in same Word document)

Sunny Day Scenarios:

csis345@csis345-vm:~$ sh printnum.sh 3

3, 2, 1

csis345@csis345-vm:~$

csis345@csis345-vm:~$ sh printnum.sh 10

10, 9, 8, 7, 6, 5, 4, 3, 2, 1

csis345@csis345-vm:~$

Rainy Day Scenarios:

csis345@csis345-vm:~$ sh printnum.sh

error: program must be executed with 1 argument. usage: printnum.sh value (where value >= 1)

csis345@csis345-vm:~$ sh printnum.sh 2 5

error: program must be executed with 1 argument. usage: printnum.sh value (where value >= 1)

csis345@csis345-vm:~$ sh printnum.sh -1

error: argument must be a positive number. usage: printnum.sh value (where value >= 1) Add at least 5 more scenarios in your Word document.

Write a Korn shell script (and show the code for it here) that will determine which file in a directory has the maximum number of lines (this may be different than the file that has the maximum number of bytes). After determining the file with the maximum number of lines, the script will print out the name of the file and the number of lines. The script must only focus on files and ignore subdirectories. The command wc may be helpful. Do not write this script to be executed interactively.

The script must allow either no arguments or 1 argument.

If zero arguments are specified, the script by default will examine the files in the current directory.

If 1 argument is specified, the argument must be the name of a directory. The script will then examine the files in the specified directory.

The script must be able to handle the following error conditions:

More than 1 argument is specified.

The specified argument is not a directory.

The script file name must be: maxlines.sh

The script permissions should be 705

Sample Output (provide yours in same Word document) Sunny Day Scenarios (Note: output depends on current directory and may not match the values below):

csis345@csis345-vm:~$ sh maxlines.sh

File maxlines.sh has maximum number lines (36 lines).

csis345@csis345-vm:~$ sh maxlines.sh /etc

File mime.types has the maximum lines with 827 lines.

Rainy Day Scenarios:

csis345@csis345-vm:~$ sh maxlines.sh junk

error: argument must be a directory usage: maxlines.sh [directory]

csis345@csis345-vm:~$ sh maxlines.sh junk trash

error: can only use 0 or 1 arguments. usage: maxlines.sh [directory] Add at least 5 more scenarios in your Word document.

Submit a zip file with all Korn Shell script files for parts a and b.

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Identify specific IT applications for HR planning.

Answered: 1 week ago