OPA JUNE 12 Unix 

Student details are stored in following format:


Roll no,Name,Subject1_Score,Subject2_Score


Write the unix command to display the roll no , name and average of scores of all the students whose score is more than 50 in every subject and whose average is more than or equals to 75 . The student details are to be displayed, sorted in descending order of the average score.


The Average score is to be calculated as follows :

Average score = (Subject1_Score + Subject2_Score)/2


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 in your file, where you have written the commands.


Note : The Roll No , Name and average are to be displayed with a space as the delimiter in the output

Sample input:

Roll no,Name,Subject1_Score,Subject2_Score

sample output:

104 shiva 79.5

101 kumar 77.5


Try in online compiler -> click here


awk 'BEGIN{FS=","} { if($3>50 && $4>40) { avg=($3+$4)/2; if(avg>=75) print $1,$2,avg}}'|sort -k3 -nr