awk if command that works to print column 19 only but how would i get it to print both columns?

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











up vote
0
down vote

favorite












I want to print column 3 and 4 but without printing the headers empty column lines.



header
tap
norm
X Y 880 1787
X Y 3253 3439


Printing this via awk 'print($3,$4)' gives



(BLANK lines from header rows)
880 1787
3253 3439


This works to print column 19 only but how would I get it to print both columns?



awk '$3print $3' 
880
3253


I want col3 col4



880 1787
3253 3439


I tried but get only column 3 printed



awk '$3print $3''$4print $4' 
880
1787
3253
3439






share|improve this question


















  • 1




    It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
    – Nasir Riley
    Apr 10 at 1:26










  • Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
    – muru
    Apr 10 at 4:47














up vote
0
down vote

favorite












I want to print column 3 and 4 but without printing the headers empty column lines.



header
tap
norm
X Y 880 1787
X Y 3253 3439


Printing this via awk 'print($3,$4)' gives



(BLANK lines from header rows)
880 1787
3253 3439


This works to print column 19 only but how would I get it to print both columns?



awk '$3print $3' 
880
3253


I want col3 col4



880 1787
3253 3439


I tried but get only column 3 printed



awk '$3print $3''$4print $4' 
880
1787
3253
3439






share|improve this question


















  • 1




    It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
    – Nasir Riley
    Apr 10 at 1:26










  • Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
    – muru
    Apr 10 at 4:47












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to print column 3 and 4 but without printing the headers empty column lines.



header
tap
norm
X Y 880 1787
X Y 3253 3439


Printing this via awk 'print($3,$4)' gives



(BLANK lines from header rows)
880 1787
3253 3439


This works to print column 19 only but how would I get it to print both columns?



awk '$3print $3' 
880
3253


I want col3 col4



880 1787
3253 3439


I tried but get only column 3 printed



awk '$3print $3''$4print $4' 
880
1787
3253
3439






share|improve this question














I want to print column 3 and 4 but without printing the headers empty column lines.



header
tap
norm
X Y 880 1787
X Y 3253 3439


Printing this via awk 'print($3,$4)' gives



(BLANK lines from header rows)
880 1787
3253 3439


This works to print column 19 only but how would I get it to print both columns?



awk '$3print $3' 
880
3253


I want col3 col4



880 1787
3253 3439


I tried but get only column 3 printed



awk '$3print $3''$4print $4' 
880
1787
3253
3439








share|improve this question













share|improve this question




share|improve this question








edited Apr 10 at 6:07









Filipe Brandenburger

3,451621




3,451621










asked Apr 10 at 0:10









Dominique

33




33







  • 1




    It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
    – Nasir Riley
    Apr 10 at 1:26










  • Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
    – muru
    Apr 10 at 4:47












  • 1




    It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
    – Nasir Riley
    Apr 10 at 1:26










  • Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
    – muru
    Apr 10 at 4:47







1




1




It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
– Nasir Riley
Apr 10 at 1:26




It is easier to get the help you need if you provide the contents of the file you're working with. What do mean by empty column lines? If you just want to print both columns then the man page for awk or google will help you. You're on the right track.
– Nasir Riley
Apr 10 at 1:26












Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
– muru
Apr 10 at 4:47




Please format example input and output with code formatting. See unix.stackexchange.com/editing-help/#code
– muru
Apr 10 at 4:47










2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










You know how long the head is (three lines):



awk 'NR > 3 print $3, $4 '


NR is the number of records (lines by default) that has been read so far. With NR > 3 we trigger the print statement for the fourth line and all lines after.



You could use



awk '$3 print $3, $4 '


but this is a bit fragile as it depends on not only $3 being present but also that it is non-zero (a zero in the third column would give no output for that line).






share|improve this answer



























    up vote
    0
    down vote













    If



    header
    tap
    norm
    X Y 880 1787
    X Y 3253 3439


    Then



    awk 'print $3 " " $4' | sed '/^ *$/d'


    Makes



    880 1787
    3253 3439


    And for your last part you can try



     awk 'print $3 " " $4 " " $19'


    To print the 3rd, 4th and 19th columns.






    share|improve this answer






















      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%2f436651%2fawk-if-command-that-works-to-print-column-19-only-but-how-would-i-get-it-to-prin%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      You know how long the head is (three lines):



      awk 'NR > 3 print $3, $4 '


      NR is the number of records (lines by default) that has been read so far. With NR > 3 we trigger the print statement for the fourth line and all lines after.



      You could use



      awk '$3 print $3, $4 '


      but this is a bit fragile as it depends on not only $3 being present but also that it is non-zero (a zero in the third column would give no output for that line).






      share|improve this answer
























        up vote
        1
        down vote



        accepted










        You know how long the head is (three lines):



        awk 'NR > 3 print $3, $4 '


        NR is the number of records (lines by default) that has been read so far. With NR > 3 we trigger the print statement for the fourth line and all lines after.



        You could use



        awk '$3 print $3, $4 '


        but this is a bit fragile as it depends on not only $3 being present but also that it is non-zero (a zero in the third column would give no output for that line).






        share|improve this answer






















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You know how long the head is (three lines):



          awk 'NR > 3 print $3, $4 '


          NR is the number of records (lines by default) that has been read so far. With NR > 3 we trigger the print statement for the fourth line and all lines after.



          You could use



          awk '$3 print $3, $4 '


          but this is a bit fragile as it depends on not only $3 being present but also that it is non-zero (a zero in the third column would give no output for that line).






          share|improve this answer












          You know how long the head is (three lines):



          awk 'NR > 3 print $3, $4 '


          NR is the number of records (lines by default) that has been read so far. With NR > 3 we trigger the print statement for the fourth line and all lines after.



          You could use



          awk '$3 print $3, $4 '


          but this is a bit fragile as it depends on not only $3 being present but also that it is non-zero (a zero in the third column would give no output for that line).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 10 at 6:36









          Kusalananda

          102k13200317




          102k13200317






















              up vote
              0
              down vote













              If



              header
              tap
              norm
              X Y 880 1787
              X Y 3253 3439


              Then



              awk 'print $3 " " $4' | sed '/^ *$/d'


              Makes



              880 1787
              3253 3439


              And for your last part you can try



               awk 'print $3 " " $4 " " $19'


              To print the 3rd, 4th and 19th columns.






              share|improve this answer


























                up vote
                0
                down vote













                If



                header
                tap
                norm
                X Y 880 1787
                X Y 3253 3439


                Then



                awk 'print $3 " " $4' | sed '/^ *$/d'


                Makes



                880 1787
                3253 3439


                And for your last part you can try



                 awk 'print $3 " " $4 " " $19'


                To print the 3rd, 4th and 19th columns.






                share|improve this answer
























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  If



                  header
                  tap
                  norm
                  X Y 880 1787
                  X Y 3253 3439


                  Then



                  awk 'print $3 " " $4' | sed '/^ *$/d'


                  Makes



                  880 1787
                  3253 3439


                  And for your last part you can try



                   awk 'print $3 " " $4 " " $19'


                  To print the 3rd, 4th and 19th columns.






                  share|improve this answer














                  If



                  header
                  tap
                  norm
                  X Y 880 1787
                  X Y 3253 3439


                  Then



                  awk 'print $3 " " $4' | sed '/^ *$/d'


                  Makes



                  880 1787
                  3253 3439


                  And for your last part you can try



                   awk 'print $3 " " $4 " " $19'


                  To print the 3rd, 4th and 19th columns.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 10 at 6:35

























                  answered Apr 10 at 5:15









                  CubeSyVal

                  85




                  85






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436651%2fawk-if-command-that-works-to-print-column-19-only-but-how-would-i-get-it-to-prin%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?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?