Awk script runs, no error, no output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DeepNik
    New Member
    • Feb 2010
    • 4

    Awk script runs, no error, no output

    I have simple awk scripts which copies information from one file based on the conditions satisfied and pastes to another. When I execute this script, no eeor is invoked, it just runs without doing anything and when I abort it using ctrl D, it executes END loop and prints Done on the terminal. What is wrong with my script. Any suggestion/advice.

    Thank you.
    Deepa
    Code:
    #!/bin/awk -f
    BEGIN {
    f1="all_CopyM.txt";
    f2= "all_domega.txt";
    }
    {
    if ($1 == "A" || "T" && $6 == "ASN" || $6 == "GLN" || $6 == "PRO" || $6 == "THR" || $6 == "SER" || $6 == "CYS"){
    	print $0 f1 > f2 ;
    	}
    }
    
    END {
        print "Done";
    }
    Last edited by numberwhun; Mar 28 '10, 06:16 PM. Reason: Please use CODE TAGS!!!
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    I don't know if its just me, but I don't see where you are setting up variables $1 and $6. You defined f1 and f2 and did an if statement. There is nothing to lead up to the if statement for it to go on. The program did exactly as it was told.

    Regards,

    Jeff

    Comment

    • rski
      Recognized Expert Contributor
      • Dec 2006
      • 700

      #3
      You didn't see the source file but i think the if statement should be
      Code:
      if ((($1 == "A")||($1== "T")) && ($6 == "ASN" || $6 == "GLN" || $6 == "PRO" || $6 == "THR" || $6 == "SER" || $6 == "CYS")){

      Comment

      Working...