I have some problem with this.
Need to change field #3 to 5 if field #1 = A and filed #2 =B
Data
A C 6 T
C B 4 R
A B 3 T
D E 5 4
I would like to do two things if statement is true, but can not get it to work.
Here it prints column #3 if statement is true, and this works
awk '{if ($1=="A" && $2=="B") print $3; else print $0}'
Here is what I have tested:
awk '{if ($1=="A" && $2=="B") $3=5 print $0; else print $0}'
awk '{if ($1=="A" && $2=="B") $3=5; print $0; else print $0}'
awk '{if ($1=="A" && $2=="B") ($3=5 print $0); else print $0}'
awk '{if ($1=="A" && $2=="B") ($3=5; print $0); else print $0}'
All gives error.
I know this can be done in other ways, but I like to learn how to make to things in one if