Question: CAN ANYONE ELSE PLEASE DO THIS USING MY CODE IT IS FOR LAB TECHNIQUES...NEED ASAP PLEASE THANK YOU !!! IT IS IN AWK IN LINUX
CAN ANYONE ELSE PLEASE DO THIS USING MY CODE IT IS FOR LAB TECHNIQUES...NEED ASAP PLEASE THANK YOU !!! IT IS IN AWK IN LINUX
# stop when we get a zero $1 == 0 { exit } # jumps to END condition # special steps for first line only NR == 1 { max = $1 } # All lines (including first) { total += $1 }
# print results at end of data (or on zero) END { if (NR == 0 || ( NR == 1 && $1 == 0 ) ) { printf("# items: 0 ") } else { if ( $1 == 0 ) { # don't count the sentinel value NR -= 1 } printf("# items: %d ", NR) printf("Total: %f ", total)
printf("Average: %f ", total / NR) } }
modify the program so that it also prints out the maximum and minimum values, as below:
elvis> ./stats.awk 1 2 3 5 0 # items: 4 Total: 11.000000 Maximum: 5.000000 Minimum: 1.000000 Average: 2.7500000 elvis>
IT IS C LANGUAGE BUT I WANT IT IN THE EXACT SAME WAY I GAVE THE SAMPLE CODE IT IS IN LINUX
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
