[Solved] COMP2560 Lab #10 Shell Script: Arrays

$25

File Name: COMP2560_Lab_#10__Shell_Script:_Arrays.zip
File Size: 357.96 KB

SKU: [Solved] COMP2560 Lab #10 – Shell Script: Arrays Category: Tag:
5/5 - (1 vote)

Use array to write a shell script to print out the information about the files and directories in the current directory according to the following sample run.

>>>>> ls

compute print repeat

>>>>> compute

practice: shell command and array

list all directories and files in current directory: compute print repeat

total number of files and directories: 3 the first element in this list: compute all elements in this list:

compute print repeat >>>>>

Part II (choice A)

Two files courses and emails are given where columns are separated by tabs.

courses:

101 60212 90
101 60256 81
102 60231 70
102 60212 85
103 60256 n/a

emails:

Write a bash script to find the emails of all students taking a specific course, which is given as a command line argument.

Hints: use grep command for the search, and use array to store intermediate data.

Sample output:

>>>>> mysolution

usage: mysolution course-number >>>>> mysolution 60200 course number 60200 not found

>>>>> mysolution 60256

[email protected]

[email protected]

Part II (choice B)

Two files 60-256 and 60-212 are given. Each contains two columns for student ids and the marks. Columns are separated by tabs. Write a bash script to print out all the ids of the students who passed both 60-256 and 60-212.

Part III (optional)

In the current directory, there are several files starting with 60-. The total number of such files could be changed, and the names of these files are not known. Each file contains two columns: student ids and the marks. Columns are separated by tabs. Write a bash script to print out all the ids of the students who passed all the courses.

2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP2560 Lab #10 Shell Script: Arrays
$25