Dear All,
Good Day. I would like to solve the following issue and got some strange results, if anyone could help me in this regard, you are most welcome.
Here is the problem:
I have a file like
Header Value1 Value2 Value3 Value4 Value5 Value6 ... Value9
12.144 6 5 5 4 3 2 ...
10.2567 10 8 6 4 4 4 ...
22.2 2 2 1 1 1 1 ...
.................................
.................................
The above-mentioned file have more than 500 rows and 10 columns.
I would like to print a new additional columns (say for example column11 and column12), where the values from column2 to column9 can satisfy the following conditions:
if ($i > 5 && $(i+1) < 5) ------ print the column header (for example, in the first row case, Value 4) should be printed in column11 and at the same time,
if ($i > 3 && $(i+1) < 3) ------ print the column header (for example, in the first row case, Value 6) should be printed in column12 (in the output file with the same format).
I tried the following code, but i couldn't get the same number of rows. here is my code:
awk '{for(i=2; i<=NF; i++) {if($i > 5 && $(i+1) < 5) print $1=(i*5); else print ""}}' inputfile > outputfile
Expecting your reply and thanks in advance.
Warm regards
Fredrick.