OPA JUNE 19 Unix 

Student details are stored in following format:

Roll no, Name, Standard, Science_Score, Mathematics_Score, SchoolName
Write the unix command to display all the fields in the same order as above for all the students whose score is more than 80 in mathematics and mathematics score should be the top score, among all the subjects for the respective student . The student details are to be displayed sorted in the ascending order of Standard (in which student studying) and ascending order of Mathematics score(If first sort parameter value is same for two or more students).


Refer sample test case below for more details.

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

♦ Sample test case

Test case Input


Test case output:





The students , whose score is greater than 80 in mathematics and the Mathematics score is more than other subject(science) score are: RajaR ,Chandra,Bharath, After sorting the filtered records as per given requirement the output will be as below.
11RajaRI9160185ISM 61Chandra19175192IDAV 51Bharathl10180188ISM
The above records displayed 9th class students first and later 10th class students nect but there are two students with 9th standard and hence the two records inturn sorted in the ascending order of Mathematics score. Here records are sorted using two sort parameters (standard and Mathematics score) in one go, ie two level sorting. Note: Extra line of space should not be there in between the output records .
Two level sorting means , Records will be sorted using second sort parameter / argument(Mathematics in this example) if and only if there are multiple records having the same value(for a field / column) after first level of sorting wrt the first sort parameter(Standard in this example).








Try in online compiler -> click here

sort -k3 -n -t "," |
awk 'BEGIN{FS=","};{if(($5>80 && $5>$4)) {print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6}}'