TCS CPA Unix Solution | Xplore UNIX CPA Solution | Count Semesters | 27 March

by Python EveryDay in Circuits > Linux

4730 Views, 1 Favorites, 0 Comments

TCS CPA Unix Solution | Xplore UNIX CPA Solution | Count Semesters | 27 March

TCS CPA UNIX Solution | EASIEST METHOD EVER!! | Xplore Unix Questions and Solution | TCS | Part 8

Unix CPA 27 march Count Semesters

Write the Unix command to print the count of subjects in each semester. You have a file having Subject details in the following format:

Subject|Semester|Grade

There are three fields and each field is separated by a pipe "|".

In the output, the semester name and the count of subjects offered in that semester needs to be displayed in ascending order of the Semester name.

Refer the sample input and output for more clarity to input file content's format and the format of the output.

The file name will be provided
as command line argument when the script containing your command will run.

You can use shell variables (ex: $0, $1, $2) whichever is applicable for your requirement to provide the command line argument.

For more clarity, please refer to the sample input and output below.

The input file with the data mentioned in the sample input, automatically supplied to the script or command you are writing.

You just need to read the file, which is supplied as command line argument and process the data in the file towards the given requirement.

Input:

Subject|Semester|Grade

Python|Sem 2|9

C Programming|Sem 3|10

Data Structures|Sem 2|5

JavaScript|Sem 3|7

DBMS|Sem 1|8

Output:

Sem 1 1
Sem 2 2
Sem 3 2

For Solution : Detailed Solution, Click Here

Python EveryDay!!!

Q2_1.JPG

Q2_2.JPG