OPA JUNE 05 Unix 

OPA-Java-Unix : Student Details

Student details are stored in following format:


Roll no,Name,Score1,Score2


Write the unix command to display the roll no and the name of all the students whose total score is greater than 100. The student details are to be displayed sorted in descending order of the the total score.


The total score is to be calculated as follows :

Total score = Score1 + Score2


The student details are provided as command line argument when the file containing your command will run. Use appropriate command line argument($1,$2 etc.) to access the details.


Note : The Roll No and Name are to be displayed with a space as the delimiter.


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


Input Format    words in the box used for tom Testing.

Input data (From Test case input or from Custom input field ) will be supplied to the shell script through commandline argument.

You just need to use the appropriate commandline argument in the shell script to read the content into a file and process the file towards the given requirement.


To test your code with custom input option the respective checkbox needs to be enabled to enter the line of words in the text field .


Instructions to read from custom input text field:

1.The first line contains the header line as displayed above in the question(Roll No, Name,Score1,Score2)

2.The next line contains the Roll No, Name, Score1 and Score2 for the first student separated by comma.

3. The subsequent lines contains the details of the rest of the students provided one by one as mentioned in Point 2.


For more details, refer to the sample Input format.



Sample test case

Test case Input

Roll No,Name,Score1,Score2






Test case output

400 Naina

123 Hari

812 Ravi

567 Amy



awk -F "," '{s=$3+$4; if (s>99) {print $1,$2,s}}'| sort -k3rn|cut -d ' ' -f1,2

Try in online compiler -> click here