write the unix command to display roll, name and avg of all students whose score is more than 50 in each subject and average is more than or equal to 75.
avg can be calculated as (subj_1+subj_2)/2.
input:
roll ,name,subScore1,subScore2 123,a,88,78 101,b,76,90 812,c,78,98 output:
123 a 83 812 c 78 my code:
awk 'BEGIN {FS=',';OFS=' '} {if(NR>1 (&& $3>50 && $4>50) && ($3+$4)/2 >= 75){print $1,$2,($3+$4)/2}}' input_file I don't know why I'm getting error. please help guys.
NR>1 -eawkis notshell, it has it's own (different) language. There is no-e. What do you mean by-e? What should it do?OFSas space since its default value itself will be space. Logic wise it looks ok but I haven't tested it, also you don't need&&in few places which I believe you are already aware of. Thanks for sharing your efforts, keep it up and make sure you always add your efforts in form of code in your questions which is highly encouraged on SO, happy learning.awk 'BEGIN {FS=',';OFS=' '}, syntactically you needawk 'BEGIN {FS=",";OFS=" "}(but of courseOFS=" "isn't actually doing anything as that's the default setting). wrtif(NR>1 (&& $3>50...- there's no language I'm aware of where you'd writecond1 (&& cond2)instead ofcond1 && (cond2)just like you did in the rest of your script.