using grep --recursive, how to exclude specific line with the 'unwanted' and 'wanted' word in it?

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











up vote
2
down vote

favorite












I'm currently building my dotfiles and I want to list all TODO: ... comments in my project's directory, I created a bash alias to do this:



 alias mytodo='grep --recursive "TODO: "'


It works well, however, it also returns the alias definition. this is the sample output.



 devs@dotfiles$ mytodo

bash/profile.d/aliases/: alias mytodo='grep --recursive "TODO: "'
bin/git_branch_status/: # TODO: Add checking of remote branch status.
tools/setup/: # TODO: Add search for existing symlinks.


how can I specifically exclude that line with the alias definition?










share|improve this question



























    up vote
    2
    down vote

    favorite












    I'm currently building my dotfiles and I want to list all TODO: ... comments in my project's directory, I created a bash alias to do this:



     alias mytodo='grep --recursive "TODO: "'


    It works well, however, it also returns the alias definition. this is the sample output.



     devs@dotfiles$ mytodo

    bash/profile.d/aliases/: alias mytodo='grep --recursive "TODO: "'
    bin/git_branch_status/: # TODO: Add checking of remote branch status.
    tools/setup/: # TODO: Add search for existing symlinks.


    how can I specifically exclude that line with the alias definition?










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I'm currently building my dotfiles and I want to list all TODO: ... comments in my project's directory, I created a bash alias to do this:



       alias mytodo='grep --recursive "TODO: "'


      It works well, however, it also returns the alias definition. this is the sample output.



       devs@dotfiles$ mytodo

      bash/profile.d/aliases/: alias mytodo='grep --recursive "TODO: "'
      bin/git_branch_status/: # TODO: Add checking of remote branch status.
      tools/setup/: # TODO: Add search for existing symlinks.


      how can I specifically exclude that line with the alias definition?










      share|improve this question















      I'm currently building my dotfiles and I want to list all TODO: ... comments in my project's directory, I created a bash alias to do this:



       alias mytodo='grep --recursive "TODO: "'


      It works well, however, it also returns the alias definition. this is the sample output.



       devs@dotfiles$ mytodo

      bash/profile.d/aliases/: alias mytodo='grep --recursive "TODO: "'
      bin/git_branch_status/: # TODO: Add checking of remote branch status.
      tools/setup/: # TODO: Add search for existing symlinks.


      how can I specifically exclude that line with the alias definition?







      bash grep






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 19 mins ago

























      asked 59 mins ago









      John Fred Fadrigalan

      2314




      2314




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          One way to prevent a regexp from hitting itself is to enclose a single character in a character class:



          alias mytodo='grep --recursive "TOD[O]:"'





          share|improve this answer




















          • it works now! Thanks. I will accept this as the answer..
            – John Fred Fadrigalan
            40 mins ago

















          up vote
          3
          down vote













          You can simply pipe it into grep -v 'alias' to get all lines which don't contain alias.






          share|improve this answer




















          • it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
            – John Fred Fadrigalan
            46 mins ago











          • @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
            – JigglyNaga
            42 mins ago










          • I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
            – John Fred Fadrigalan
            34 mins ago











          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%2f470226%2fusing-grep-recursive-how-to-exclude-specific-line-with-the-unwanted-and-wa%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
          4
          down vote



          accepted










          One way to prevent a regexp from hitting itself is to enclose a single character in a character class:



          alias mytodo='grep --recursive "TOD[O]:"'





          share|improve this answer




















          • it works now! Thanks. I will accept this as the answer..
            – John Fred Fadrigalan
            40 mins ago














          up vote
          4
          down vote



          accepted










          One way to prevent a regexp from hitting itself is to enclose a single character in a character class:



          alias mytodo='grep --recursive "TOD[O]:"'





          share|improve this answer




















          • it works now! Thanks. I will accept this as the answer..
            – John Fred Fadrigalan
            40 mins ago












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          One way to prevent a regexp from hitting itself is to enclose a single character in a character class:



          alias mytodo='grep --recursive "TOD[O]:"'





          share|improve this answer












          One way to prevent a regexp from hitting itself is to enclose a single character in a character class:



          alias mytodo='grep --recursive "TOD[O]:"'






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 50 mins ago









          JigglyNaga

          2,721623




          2,721623











          • it works now! Thanks. I will accept this as the answer..
            – John Fred Fadrigalan
            40 mins ago
















          • it works now! Thanks. I will accept this as the answer..
            – John Fred Fadrigalan
            40 mins ago















          it works now! Thanks. I will accept this as the answer..
          – John Fred Fadrigalan
          40 mins ago




          it works now! Thanks. I will accept this as the answer..
          – John Fred Fadrigalan
          40 mins ago












          up vote
          3
          down vote













          You can simply pipe it into grep -v 'alias' to get all lines which don't contain alias.






          share|improve this answer




















          • it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
            – John Fred Fadrigalan
            46 mins ago











          • @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
            – JigglyNaga
            42 mins ago










          • I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
            – John Fred Fadrigalan
            34 mins ago















          up vote
          3
          down vote













          You can simply pipe it into grep -v 'alias' to get all lines which don't contain alias.






          share|improve this answer




















          • it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
            – John Fred Fadrigalan
            46 mins ago











          • @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
            – JigglyNaga
            42 mins ago










          • I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
            – John Fred Fadrigalan
            34 mins ago













          up vote
          3
          down vote










          up vote
          3
          down vote









          You can simply pipe it into grep -v 'alias' to get all lines which don't contain alias.






          share|improve this answer












          You can simply pipe it into grep -v 'alias' to get all lines which don't contain alias.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 55 mins ago









          Panki

          1717




          1717











          • it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
            – John Fred Fadrigalan
            46 mins ago











          • @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
            – JigglyNaga
            42 mins ago










          • I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
            – John Fred Fadrigalan
            34 mins ago

















          • it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
            – John Fred Fadrigalan
            46 mins ago











          • @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
            – JigglyNaga
            42 mins ago










          • I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
            – John Fred Fadrigalan
            34 mins ago
















          it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
          – John Fred Fadrigalan
          46 mins ago





          it works with grep -v 'alias' | grep -r 'TODO: ' but for some reason it messed up the colors of the grep output.. any idea why?
          – John Fred Fadrigalan
          46 mins ago













          @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
          – JigglyNaga
          42 mins ago




          @JohnFredFadrigalan Do you already have a grep alias? That's typically where the color option is set.
          – JigglyNaga
          42 mins ago












          I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
          – John Fred Fadrigalan
          34 mins ago





          I already aliased the grep with --color=auto so i think its because of the piping.. I tried to reverse the order of the command and it works with colored output but it freezes.
          – John Fred Fadrigalan
          34 mins ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470226%2fusing-grep-recursive-how-to-exclude-specific-line-with-the-unwanted-and-wa%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          Confectionery