I am using grep within a script to obtain a list of filenames of the files that contain a certain string. The basic instruction would be this one within a do loop:
if grep -q "$str" Inputs/inp$n; then echo inp$n >> file_list.txt fi
And something like this to get the lines themselves for verification purposes:
grep "$str" Files/inp$n >> lines.txt
What I would like to do is prevent some false positives from showing up in the output when looking for certain strings. I would like to get the lines containing "abc#", where "#" is a number (multiple digits possible), but I do not want the specific word "abcde" from appearing when I am searching for the string "abc". Note that "abc#" and "abcde" are not present in the same line within these files.
Is there any way to tell grep to ignore the lines that contain "abcde" among those containing "abc"?