I have file as shown below .I have to find the maximum value for each timestamp. So I have to find the max(2434, 2681, 2946, 1626) , max(3217, 4764, 4501, 3372) and so on ... (since these numbers have a common timestamp)
Timestamp value
1280449531 2434
1280449531 2681
1280449531 2946
1280449531 1626
1280449532 3217
1280449532 4764
1280449532 4501
1280449532 3372
1280449533 4129
1280449533 6937
1280449533 6423
1280449533 4818
1280449534 4850
1280449534 8980
1280449534 8078
1280449534 6788
1280449535 5587
1280449535 10879
1280449535 9920
1280449535 8146
1280449536 6324
1280449536 12860
1280449536 11612
1280449536 9867
I wrote this code but getting errors. Can somebody correct me ? Thanks in advance
#!/bin/bash
awk '{ if [ temp -ne $1 ]
then temp = $1; big[$1] = $2
fi
elif [temp -eq $1] then if [$2 gt $big[$1] ] big[$1] = $2 ; fi
fi
}' plots.dat