grep: find files that do not have multiple different strings
Hi all,
I'm trying to identify files that do not have matches for certain strings. FYI, these are files of DNA sequences and I'm trying to find those that are NOT sampled for any species by my group of interest (e.g., genes that are specific to that group of organisms). I tried this code but it's actually yielding a list of files that DO match for my regexp. Code:
for FILENAME in *.fas Best, Kevin |
awk would be better I think (or perl, python ...)
Code:
(pseudo code) |
first, using -q and and -L together seems a bit nonsensical. -L tells grep to print filenames that don't match, but -q supresses the output.
Also, you seem to be confusing standard output of the program and its return code. The && operators depend on the latter, while -L affects the former. So, if the file does contain the first pattern, grep returns 0 and the next grep is executed. If, however, the first pattern is not included, grep prints nothing because of the -q switch and returns 1, which means the tests for the other patterns are not executed. Also, you are running the greps in a loop, but the -L switch makes most sense when executed with multiple filenames to list those that don't match. So, some possibilities: Code:
grep -L "PBAH\|SKOW\|CGRA" *.fas Code:
grep -L -f patterns *.fas |
Thanks guys! Very helpful!
|
glad to help you
(if you really want to say thanks just click on yes) |
All times are GMT -5. The time now is 03:06 PM. |