UNIX: excluding patterns, contained in a file, from another file with grep
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have a txt file that contains the patterns I would like to exclude from a file. Is there a way to chain grep -f
and grep -v
?
Thanks
grep
add a comment |Â
up vote
2
down vote
favorite
I have a txt file that contains the patterns I would like to exclude from a file. Is there a way to chain grep -f
and grep -v
?
Thanks
grep
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a txt file that contains the patterns I would like to exclude from a file. Is there a way to chain grep -f
and grep -v
?
Thanks
grep
I have a txt file that contains the patterns I would like to exclude from a file. Is there a way to chain grep -f
and grep -v
?
Thanks
grep
edited Jun 9 '16 at 21:24
sam
12.3k31326
12.3k31326
asked Jun 9 '16 at 21:11
Nicholas Hayden
355
355
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
You can use the options together like:
grep -vf exclude.txt file.txt
Example:
$ cat exclude.txt
3
$ cat file.txt
1
3
4
1
4
3
1
2
$ grep -vf exclude.txt file.txt
1
4
1
4
1
2
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
@NicholasHayden, you might want to check out the-x
and-F
options inman grep
.
â Wildcard
Jun 9 '16 at 21:39
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
You can use the options together like:
grep -vf exclude.txt file.txt
Example:
$ cat exclude.txt
3
$ cat file.txt
1
3
4
1
4
3
1
2
$ grep -vf exclude.txt file.txt
1
4
1
4
1
2
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
@NicholasHayden, you might want to check out the-x
and-F
options inman grep
.
â Wildcard
Jun 9 '16 at 21:39
add a comment |Â
up vote
4
down vote
You can use the options together like:
grep -vf exclude.txt file.txt
Example:
$ cat exclude.txt
3
$ cat file.txt
1
3
4
1
4
3
1
2
$ grep -vf exclude.txt file.txt
1
4
1
4
1
2
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
@NicholasHayden, you might want to check out the-x
and-F
options inman grep
.
â Wildcard
Jun 9 '16 at 21:39
add a comment |Â
up vote
4
down vote
up vote
4
down vote
You can use the options together like:
grep -vf exclude.txt file.txt
Example:
$ cat exclude.txt
3
$ cat file.txt
1
3
4
1
4
3
1
2
$ grep -vf exclude.txt file.txt
1
4
1
4
1
2
You can use the options together like:
grep -vf exclude.txt file.txt
Example:
$ cat exclude.txt
3
$ cat file.txt
1
3
4
1
4
3
1
2
$ grep -vf exclude.txt file.txt
1
4
1
4
1
2
answered Jun 9 '16 at 21:13
heemayl
33.1k36897
33.1k36897
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
@NicholasHayden, you might want to check out the-x
and-F
options inman grep
.
â Wildcard
Jun 9 '16 at 21:39
add a comment |Â
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
@NicholasHayden, you might want to check out the-x
and-F
options inman grep
.
â Wildcard
Jun 9 '16 at 21:39
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
Thanks! However, grep does not seem to filtering based on exclude.txt - Would there be a problem with the exclude.txt?
â Nicholas Hayden
Jun 9 '16 at 21:19
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
@NicholasHayden Thats the way to go. If you have any problem then it must be with the patterns.
â heemayl
Jun 9 '16 at 21:22
1
1
@NicholasHayden, you might want to check out the
-x
and -F
options in man grep
.â Wildcard
Jun 9 '16 at 21:39
@NicholasHayden, you might want to check out the
-x
and -F
options in man grep
.â Wildcard
Jun 9 '16 at 21:39
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%2f288809%2funix-excluding-patterns-contained-in-a-file-from-another-file-with-grep%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