I have data with three fields. Fields 2 and 3 can be zero and I want to change to "." if it is zero.
Example data:
1 0 0
2 0 0
3 0 0
4 0 1
5 1 0
Here is what I tried:
awk '{
if($2=="0" && $3=="0"){
`$3=".";`
`$2=".";`
}
else if($3=="0"){
$3="."
}
else if($2=="0"){
$2="." }
else {
$2=$2;
$3=$3;
}
print $0
}' file.txt>changedfile.txt
It changed only the second field but not the third field. Thanks a lot, I want to do it with Awk control structure