I have a dataset with > 7 Mio rows (and in reality >20 columns), and would like to create a new column (my dataset example has 5 columns), so this would be number 6. My dataset has a header.
The conditions should be as follows: If the values of column 1 is larger than that of column 3, then the new column should have the value of column 1; otherwise it should have the value of "1 minus the value of column 1".
I tried this, but it does not work:
awk '{ if ($1 > $3) $6 == $1}; else $6 == 1-$1}' test.txt > test2.txt
Dataset (example):
col1 col2 col3 col4 col5
1 3 4 string string
4 2 1 string string
For line 1 col6 should be 1-1 = 0
, for line 2 col6 should be 4
.