title: awk syntax error: syntax error at source line 1
body: <p>The following is an example of some contents in an input file:</p>
  
  <pre><code>                       username: thebestusernamethereis
                      EMAILID: someemail@address.com
                 enc_username: NULL
                 MACHINE_CODE: NULL
                    FIRSTNAME: John
                     LASTNAME: Doe
                     ADDRESS1: NULL
                     ADDRESS2: NULL
                      COUNTRY: NULL
                         CITY: NULL
                        STATE: NULL
                        ZCODE: NULL
              ACTIVATION_CODE: NULL
               ACCOUNT_STATUS: Y
                CREATION_DATE: 2010-07-02 12:02:33
                DEFAULT_DRIVE: NULL
      EXCHANGE_BACKUP_ALLOWED: N
  SYSTEM_STATE_BACKUP_ALLOWED: N
            CHECKSUM_1_METHOD: NULL
            CHECKSUM_2_METHOD: NULL
            additional_flag_1: NULL
            additional_flag_2: NULL
            additional_flag_3: F
                       USEDBY: F
               DATABASE_DRIVE: NULL
                maxquotalimit: 2147483648
                CURQUOTALIMIT: 0
               ECOMMERCE_FLAG: NULL
                        phone:
            cancellation_date: NULL
                 proxy_server: sb.domain.com
                   proxy_port: 20000
            proxy_port_server: 10001
                    num_accts: NULL
                   license_cd: NULL
         IDRIVE_DEFAULT_DRIVE: NULL
  international_additional_flag_1: M
              move_identifier: NULL
                    subscribe: N
                    client_ip: NULL
                 USEDBY_COUNT: 0
             last_update_date: NULL
                    promocode: NULL
             password_support: NULL
            UNDER MAINTENANCE: UNDEFINED
  </code></pre>
  
  <p>I have an awk line that seems to causing the error in my script. So, I tested the line as follows:</p>
  
  <pre><code>cat inputfile.txt | awk '$1 ~ /^(user_name:|EMAIL:|FIRST_NAME:|LAST_NAME:|CREATION_DATE:|REGISTRATION_STATUS:)$/{printf "%s,",$2\} $1 ~ /REGISTRATION_STATUS:/{print $2\}' inputfile.txt &gt; outputfile.txt
  </code></pre>
  
  <p>The error I receive is:</p>
  
  <pre><code>awk: syntax error at source line 1
     context is
    $1 ~ /^(user_name:|EMAIL:|FIRST_NAME:|LAST_NAME:|CREATION_DATE:|REGISTRATION_STATUS:)$/{printf &gt;&gt;&gt;  "%s,",$2\ &lt;&lt;&lt; } $1 ~ /REGISTRATION_STATUS:/{print $2\}
  awk: illegal statement at source line 1
  </code></pre>
  
  <p>The strange thing about this error is that the script was fine before I changed an output file name: old = IDL_$output_file.idl'; new = `$output_file.idl'. This is under PRODUCT4 above.</p>
  
  <p>So, I replaced this file with a backup that was working without error messages and it is still producing this error. </p>
  
  <p>I do not know what to do to resolve this. I tried changing #!/bin/sh to #!/bin/bash and have the same error. I do not know what the syntax error is.</p>
  
  <p>I am using bash on Mac El Capitan. </p>
  
  <p>Please help. Thank you!</p>