Reputation: 43
I have about ~1000 data files in format of file_1000.txt, file_1100.txt, etc.
Each of this file contains data in 2 columns and more than 2k rows (this is an example):
1.270000e-01 1.003580e+00
6.270000e-01 1.003582e+00
1.126000e+00 1.003582e+00
1.626000e+00 1.003584e+00
2.125000e+00 1.003584e+00
2.625000e+00 1.003586e+00
...
I want to find maximum value in each data file from 2nd column and store these numbers anywhere (particulary, plot in gnuplot). I tried to use the script:
cat file_1*00.txt | awk '{if ($2 > max) max=$2}END{print max}'
But it searches all files with file_1*00.txt condition and outputs only 1 number - maximum value from all these files.
How can I change the script to output maximums from ALL the files I mentioned in scrypt?
Thanks!
Upvotes: 0
Views: 868
Reputation: 1456
awk '{if(a[FILENAME]<$2)a[FILENAME]=$2}END{for(i in a)print i,a[i]}' file_1*00.txt
each file max ?
Upvotes: 2