Suppose I have two files 1.txt and 2.txt.
My aim is to find (Total execution time/Number of executions)
then sort the result as in decreasing order.
Can anyone provide me any shell/perl/awk script or a Command to do that in faster way ?
Number of executions = 738
Total execution time = 8.9823
sort -t= -nrk2,2 1.txt
Sorry, didn't read full question...
sort -t= -nrk2,2 1.txt
...will only sort the 1.txt file.....
Basically I want to do (Total execution time/Number of executions) line by line from both files....
eg
8.9823/738 = 0.012
823/23 = 35.782
9837/11383 = 0.864
8.9823/234 = 0.038
then sort the above result...
823/23 = 35.782
9837/11383 = 0.864
8.9823/234 = 0.038
8.9823/738 = 0.012
I want to also know in the output that for which "Total execution time" and "Number of executions" we are getting what results....like I pasted the above result.
Example......in above eg I can see the max is 35.782 for "Total execution time" = 823 and "Number of executions" = 23.
paste 1.txt 2.txt |
awk '{ printf "%s/%s = %3.3f\n", $10, $5, $10/$5}' |
sort -r -k3
Thanks fpmurphy !
I get the desired output but you can see the error/message in RED.
Is it safe to ignore all 3 lines? I want to make sure because for my project we have hell lots of lines in the input files and a single mistake in division or missing any line will mess our project.
$ paste 1.txt 2.txt | awk '{ printf "%s/%s = %3.3f\n", $10, $5, $10/$5}' | sort -r -k3
awk: 0602-566 Cannot divide by zero.
The input line number is 5.
The source line number is 1.
823/23 = 35.783
9837/11383 = 0.864
8.9823/234 = 0.038
8.9823/738 = 0.012