using grep --recursive, how to exclude specific line with the 'unwanted' and 'wanted' word in it?
Clash 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?
bash grep
add a comment |Â
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?
bash grep
add a comment |Â
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?
bash grep
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
bash grep
edited 19 mins ago
asked 59 mins ago
John Fred Fadrigalan
2314
2314
add a comment |Â
add a comment |Â
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]:"'
it works now! Thanks. I will accept this as the answer..
– John Fred Fadrigalan
40 mins ago
add a comment |Â
up vote
3
down vote
You can simply pipe it into grep -v 'alias'
to get all lines which don't contain alias
.
it works withgrep -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 agrep
alias? That's typically where thecolor
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
add a comment |Â
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]:"'
it works now! Thanks. I will accept this as the answer..
– John Fred Fadrigalan
40 mins ago
add a comment |Â
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]:"'
it works now! Thanks. I will accept this as the answer..
– John Fred Fadrigalan
40 mins ago
add a comment |Â
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]:"'
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]:"'
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
add a comment |Â
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
add a comment |Â
up vote
3
down vote
You can simply pipe it into grep -v 'alias'
to get all lines which don't contain alias
.
it works withgrep -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 agrep
alias? That's typically where thecolor
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
add a comment |Â
up vote
3
down vote
You can simply pipe it into grep -v 'alias'
to get all lines which don't contain alias
.
it works withgrep -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 agrep
alias? That's typically where thecolor
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
add a comment |Â
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
.
You can simply pipe it into grep -v 'alias'
to get all lines which don't contain alias
.
answered 55 mins ago
Panki
1717
1717
it works withgrep -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 agrep
alias? That's typically where thecolor
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
add a comment |Â
it works withgrep -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 agrep
alias? That's typically where thecolor
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password