How to solve this syntax error of gawk (GNU awk) on OSX terminal?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm using OSX terminal and trying to extract specified text of log file by regex.



awk version is



GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.


my trying operation is



$gawk '/123/ BEGINRS="DEBUG"; FS="n"print $0"n"END' ./app_108_utf8_T2.log > output.txt


but awk says



gawk: cmd. line:1: /123/ BEGINRS="DEBUG"; FS="n"print $0"n"END
gawk: cmd. line:1: ^ syntax error


Why does awk say error?







share|improve this question
























    up vote
    0
    down vote

    favorite












    I'm using OSX terminal and trying to extract specified text of log file by regex.



    awk version is



    GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
    Copyright (C) 1989, 1991-2018 Free Software Foundation.


    my trying operation is



    $gawk '/123/ BEGINRS="DEBUG"; FS="n"print $0"n"END' ./app_108_utf8_T2.log > output.txt


    but awk says



    gawk: cmd. line:1: /123/ BEGINRS="DEBUG"; FS="n"print $0"n"END
    gawk: cmd. line:1: ^ syntax error


    Why does awk say error?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using OSX terminal and trying to extract specified text of log file by regex.



      awk version is



      GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
      Copyright (C) 1989, 1991-2018 Free Software Foundation.


      my trying operation is



      $gawk '/123/ BEGINRS="DEBUG"; FS="n"print $0"n"END' ./app_108_utf8_T2.log > output.txt


      but awk says



      gawk: cmd. line:1: /123/ BEGINRS="DEBUG"; FS="n"print $0"n"END
      gawk: cmd. line:1: ^ syntax error


      Why does awk say error?







      share|improve this question












      I'm using OSX terminal and trying to extract specified text of log file by regex.



      awk version is



      GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
      Copyright (C) 1989, 1991-2018 Free Software Foundation.


      my trying operation is



      $gawk '/123/ BEGINRS="DEBUG"; FS="n"print $0"n"END' ./app_108_utf8_T2.log > output.txt


      but awk says



      gawk: cmd. line:1: /123/ BEGINRS="DEBUG"; FS="n"print $0"n"END
      gawk: cmd. line:1: ^ syntax error


      Why does awk say error?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 11 at 8:36









      user74176

      1125




      1125




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          I’m guessing you want to run



          gawk 'BEGINRS="DEBUG"; FS="n" /123/print $0"n"' ./app_108_utf8_T2.log > output.txt


          BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both for a single block.






          share|improve this answer




















          • Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
            – Kusalananda
            Apr 11 at 8:40











          • @user74176 If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Apr 11 at 8:42










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436950%2fhow-to-solve-this-syntax-error-of-gawk-gnu-awk-on-osx-terminal%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          I’m guessing you want to run



          gawk 'BEGINRS="DEBUG"; FS="n" /123/print $0"n"' ./app_108_utf8_T2.log > output.txt


          BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both for a single block.






          share|improve this answer




















          • Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
            – Kusalananda
            Apr 11 at 8:40











          • @user74176 If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Apr 11 at 8:42














          up vote
          3
          down vote



          accepted










          I’m guessing you want to run



          gawk 'BEGINRS="DEBUG"; FS="n" /123/print $0"n"' ./app_108_utf8_T2.log > output.txt


          BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both for a single block.






          share|improve this answer




















          • Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
            – Kusalananda
            Apr 11 at 8:40











          • @user74176 If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Apr 11 at 8:42












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          I’m guessing you want to run



          gawk 'BEGINRS="DEBUG"; FS="n" /123/print $0"n"' ./app_108_utf8_T2.log > output.txt


          BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both for a single block.






          share|improve this answer












          I’m guessing you want to run



          gawk 'BEGINRS="DEBUG"; FS="n" /123/print $0"n"' ./app_108_utf8_T2.log > output.txt


          BEGIN defines the block of instructions which run at the start of the process, and /123/ defines the block which runs when the “123” regular expression matches the current line. You can’t specify both for a single block.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 11 at 8:38









          Stephen Kitt

          140k22305365




          140k22305365











          • Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
            – Kusalananda
            Apr 11 at 8:40











          • @user74176 If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Apr 11 at 8:42
















          • Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
            – Kusalananda
            Apr 11 at 8:40











          • @user74176 If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Apr 11 at 8:42















          Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
          – Kusalananda
          Apr 11 at 8:40





          Tangentially related: You also can't use e.g. condition && END ..., which is a pity sometimes.
          – Kusalananda
          Apr 11 at 8:40













          @user74176 If this solves your issue, please consider accepting the answer.
          – Kusalananda
          Apr 11 at 8:42




          @user74176 If this solves your issue, please consider accepting the answer.
          – Kusalananda
          Apr 11 at 8:42












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436950%2fhow-to-solve-this-syntax-error-of-gawk-gnu-awk-on-osx-terminal%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay