Hi,
i've been trying to extract min and max values for the following data using awk script but failed. i keep on getting the same repeated results for both min and max and the results seems ridiculous.
I need to generate results based on Id. If column 4 is a '+', then the min value should be taken from column 2 in row 1 and max value from column 3 in the last row for that particular Id. But, if column 4 is '-', then the min value should be taken from column 2 in last row and max value should be taken from column 3 on the first row for that particular id.
sca_1 13976 14249 + Id 4 Numb 1
sca_1 14306 14416 + Id 4 Numb 2
sca_1 14661 14698 + Id 4 Numb 3
sca_1 16111 16236 + Id 5 Numb 1
sca_1 16367 16643 + Id 5 Numb 2
sca_1 21204 22151 - Id 6 Numb 2
sca_1 22217 22765 - Id 6 Numb 1
the output should be generated in a new file that contains 3 columns (id, min and max) and should look like this:-
Id 4 13976 14698
Id 5 16111 16643
Id 6 22217 22151
i have thousands of data like this in 1 file and i have hundreds of files like this that i need to sort out. i would really appreciate your kind assistance or advise on this.. thanks
i've been trying to extract min and max values for the following data using awk script but failed. i keep on getting the same repeated results for both min and max and the results seems ridiculous.
I need to generate results based on Id. If column 4 is a '+', then the min value should be taken from column 2 in row 1 and max value from column 3 in the last row for that particular Id. But, if column 4 is '-', then the min value should be taken from column 2 in last row and max value should be taken from column 3 on the first row for that particular id.
sca_1 13976 14249 + Id 4 Numb 1
sca_1 14306 14416 + Id 4 Numb 2
sca_1 14661 14698 + Id 4 Numb 3
sca_1 16111 16236 + Id 5 Numb 1
sca_1 16367 16643 + Id 5 Numb 2
sca_1 21204 22151 - Id 6 Numb 2
sca_1 22217 22765 - Id 6 Numb 1
the output should be generated in a new file that contains 3 columns (id, min and max) and should look like this:-
Id 4 13976 14698
Id 5 16111 16643
Id 6 22217 22151
i have thousands of data like this in 1 file and i have hundreds of files like this that i need to sort out. i would really appreciate your kind assistance or advise on this.. thanks