Hello All,
I have a below data in a .csv file where all rows where col1 is A, col2 is odd numbers, similarly even numbers for all rows where col1 is B.
Note that my data has some other columns(not shown here) too (around 100) after col2.
Tool,Data
A,1
A,3
A,5
....
so on
B,2
B,4
....
so on
I want to convert all odd numbers to even numbers( adding 1).. So my output is like below.
Tool,Data
A,2
A,4
A,6
.....
so on
B,2
B,4
....
so on
I need a one liner code for this without splitting the file into 2 portions and joining them later.
I tried tried like
awk -F, 'NR==1; $1=='A'' infile | awk -F, '$2=$2+1' >temp1.CSV
awk -F, '$1=='B' infile >temp2.CSV
cat temp1.CSV temp2.CSV >outfile
But I want to avoid these temporary files temp*..
Thanks
Sidda