how to use multiple if conditions in AWK? : i am quite new to awk so i have a following query.

i have below input file which i need to parse.

input.csv

"11111","TRUE","aa"

"456789","TRUE","aa;bb;cc"

"2345","TRUE","bb"

"434566","","cc"

**i am trying to create an awk command which should give me following output.**

output.csv

"11111","TRUE","aa,,"

"456789","TRUE","aa,bb,cc"

"2345","TRUE",",bb,"

"434566","",",,cc"

so i have created following command.

**awk 'BEGIN{FS=",";OFS=","}  { if( $3 ~ /aa/ ) { value="aa" }  else { value="," }; if( $3 ~ /bb/ ) { value="$value,bb" } else { value="$value," }; 
if( $3 ~ /cc/ ) { value="$value,cc" } else { value="$value,"};  print $1 , $2 , $value}' input.csv > output.csv**

But it is giving me following output.

**"11111","TRUE","11111","TRUE","aa"

"456789","TRUE","456789","TRUE","aa;bb;cc"

"2345","TRUE","2345","TRUE","bb"

"434566","","434566","","cc"**

i am not sure why it is print first two atrributes twice and then printing the third value. Can someone please help me out as i am quite new to awk although i am able to do it in shell script but i need to do it using awk.




