What's the correct syntax to use "if-else"

hi, i'm a beginner in Linux, actually i use andLinux,
i have a data file with 11 columns

170 N  SER T 25 56.962 42.701 -133.423 1.00 87.04 N
171 CA SER T 25 57.076 41.790 -132.280 1.00 86.65 C
172 C  SER T 25 57.766 40.492 -132.692 1.00 87.52 C
173 O  SER T 25 58.653 39.988 -131.992 1.00 86.59 O
174 CB SER T 25 55.694 41.451 -131.730 1.00 85.78 C
175 OG SER T 25 54.981 40.607 -132.622 1.00 77.49 O

i would like write close to 11 th column "12" if in the 11 th column is C or "14" if is N or "16" if is O,
i tried several time only for C but doesn't work

{ 
atom = $11
if  ( atom == " C " ) 
{ 
  print  $11 12
} 
else
{ 
  print  $11 "no" 
}
}

Can somebody help me???
thanks

"==" is Perl syntax.

Try "man test"

bash script

while read LINE
do
    Atom=$(echo $LINE | cut -d' ' -f11)
    case $Atom in
        C )    echo "$Atom 12" ;;
        N )    echo "$Atom 14" ;;
        O )    echo "$Atom 16" ;;
        * )    echo "$Atom no" ;;
    esac
done < data

result with your data sample :

N 14
C 12
C 12
O 16
C 12
 awk '{
if ($NF=="N") {print $11,"14"}
else if ($NF=="C") {print $11,"12"}
     else if ($NF=="O") {print $11,"16"}
           else {print $11,"no"}
} ' urfile
N 14
C 12
C 12
O 16
C 12
O 16
sed -e 's/N$/N12/' -e 's/C$/C14/' -e 's/O$/O16/'

There is one more request, if not N$, C$, O$, should print "no".

Thanks so much, but it still no working, if i prepare a file test.awk and i call it by command awk -f test.awk , it writes a column of "no". And if i try to write the command directly on the terminal, it writes nothing and the terminal become useless. :frowning:

---------- Post updated at 12:59 PM ---------- Previous update was at 10:56 AM ----------

thanks a lot, with your suggestion it works.
thank you.
Elsa:o