get rid of multiple words using sed

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











up vote
1
down vote

favorite












I'm trying to get rid of the following input using sed:



branch
branch

not
"git
"git


That is an empty line, the term branch, not and "git. However the following line does not work:



git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g' 


How can I write this line correctly to get rid of all of this at once?







share|improve this question

























    up vote
    1
    down vote

    favorite












    I'm trying to get rid of the following input using sed:



    branch
    branch

    not
    "git
    "git


    That is an empty line, the term branch, not and "git. However the following line does not work:



    git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g' 


    How can I write this line correctly to get rid of all of this at once?







    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm trying to get rid of the following input using sed:



      branch
      branch

      not
      "git
      "git


      That is an empty line, the term branch, not and "git. However the following line does not work:



      git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g' 


      How can I write this line correctly to get rid of all of this at once?







      share|improve this question













      I'm trying to get rid of the following input using sed:



      branch
      branch

      not
      "git
      "git


      That is an empty line, the term branch, not and "git. However the following line does not work:



      git status 2>&1 | awk 'print $2' | sed 's/^$//g' | sed 's/^branch||^not||^changes||^"git//g' 


      How can I write this line correctly to get rid of all of this at once?









      share|improve this question












      share|improve this question




      share|improve this question








      edited Aug 7 at 1:03









      muru

      128k19268458




      128k19268458









      asked Aug 6 at 21:07









      user99201

      1083




      1083




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          The correct way of doing what you are trying to achieve:



          git status --porcelain | sed s/^...//


          From git help status:




          --porcelain[=]

          Give the output in an easy-to-parse format for scripts. This is similar to the short output.





          And here is what you want to use with your commands:



          Using sed:



          ... | sed -r '/(^"git|^branch|^not|^$)/d'


          Using grep:



          ... | grep -Ev '^branch|^not|^"git|^$'


          Which returns file names from your git and awk command.






          share|improve this answer























          • That is REALLY helpful. Thank you!
            – user99201
            Aug 6 at 21:39










          • @user99201 You're welcome ;)
            – Ravexina
            Aug 6 at 21:41










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          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: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2faskubuntu.com%2fquestions%2f1063006%2fget-rid-of-multiple-words-using-sed%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










          The correct way of doing what you are trying to achieve:



          git status --porcelain | sed s/^...//


          From git help status:




          --porcelain[=]

          Give the output in an easy-to-parse format for scripts. This is similar to the short output.





          And here is what you want to use with your commands:



          Using sed:



          ... | sed -r '/(^"git|^branch|^not|^$)/d'


          Using grep:



          ... | grep -Ev '^branch|^not|^"git|^$'


          Which returns file names from your git and awk command.






          share|improve this answer























          • That is REALLY helpful. Thank you!
            – user99201
            Aug 6 at 21:39










          • @user99201 You're welcome ;)
            – Ravexina
            Aug 6 at 21:41














          up vote
          3
          down vote



          accepted










          The correct way of doing what you are trying to achieve:



          git status --porcelain | sed s/^...//


          From git help status:




          --porcelain[=]

          Give the output in an easy-to-parse format for scripts. This is similar to the short output.





          And here is what you want to use with your commands:



          Using sed:



          ... | sed -r '/(^"git|^branch|^not|^$)/d'


          Using grep:



          ... | grep -Ev '^branch|^not|^"git|^$'


          Which returns file names from your git and awk command.






          share|improve this answer























          • That is REALLY helpful. Thank you!
            – user99201
            Aug 6 at 21:39










          • @user99201 You're welcome ;)
            – Ravexina
            Aug 6 at 21:41












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          The correct way of doing what you are trying to achieve:



          git status --porcelain | sed s/^...//


          From git help status:




          --porcelain[=]

          Give the output in an easy-to-parse format for scripts. This is similar to the short output.





          And here is what you want to use with your commands:



          Using sed:



          ... | sed -r '/(^"git|^branch|^not|^$)/d'


          Using grep:



          ... | grep -Ev '^branch|^not|^"git|^$'


          Which returns file names from your git and awk command.






          share|improve this answer















          The correct way of doing what you are trying to achieve:



          git status --porcelain | sed s/^...//


          From git help status:




          --porcelain[=]

          Give the output in an easy-to-parse format for scripts. This is similar to the short output.





          And here is what you want to use with your commands:



          Using sed:



          ... | sed -r '/(^"git|^branch|^not|^$)/d'


          Using grep:



          ... | grep -Ev '^branch|^not|^"git|^$'


          Which returns file names from your git and awk command.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Aug 6 at 21:32


























          answered Aug 6 at 21:18









          Ravexina

          24.5k136185




          24.5k136185











          • That is REALLY helpful. Thank you!
            – user99201
            Aug 6 at 21:39










          • @user99201 You're welcome ;)
            – Ravexina
            Aug 6 at 21:41
















          • That is REALLY helpful. Thank you!
            – user99201
            Aug 6 at 21:39










          • @user99201 You're welcome ;)
            – Ravexina
            Aug 6 at 21:41















          That is REALLY helpful. Thank you!
          – user99201
          Aug 6 at 21:39




          That is REALLY helpful. Thank you!
          – user99201
          Aug 6 at 21:39












          @user99201 You're welcome ;)
          – Ravexina
          Aug 6 at 21:41




          @user99201 You're welcome ;)
          – Ravexina
          Aug 6 at 21:41












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1063006%2fget-rid-of-multiple-words-using-sed%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?