Question: (Script 2) You are supposed to write a shell script that will count total size of files which size is an odd or an even

(Script 2) You are supposed to write a shell script that will count total size of files which size is an odd or an even number (depending on the parameter given in the command line at the time the script is executed). The marking system will assume that the script will be processing two command line parameters, directory name should be first parameter and then odd or even should follow to express which files should be counted in. For the test purposes a test environment has been prepared in the scriptcheck system with a number of files. Your script will be executed in the command line as:

scriptname dir_name odd

to calculate total size of all files of odd size.

scriptname dir_name even

to calculate total size of all files of even size.

Suppose youve got the following directory structure:

A-

-a.txt (size 5 bytes)

-b.txt (size 7 bytes)

-c.txt (size 1 byte)

-d.txt (size 4 bytes)

For the example execution:

scriptname ./A odd

your script should return 13

and for example execution:

scriptname ./A even

your script should return 4.

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!