I’m trying to write a regular expression that will essentially return true if string A is found and string B is not found.
To be more specific, I’m looking for any file on my server which has the text ‘base64_decode’ in it, but not ‘copyright’.
Thanks!
I’m not sure your real task can be solved purely within the regex passed into grep, since grep processes files line-by-line. I would use the
-l(--files-with-matches) and-L(--files-without-match) options along with command substitution backticks, like so:grep -l base64_decode *lists the names of all the files with “base64_decode” in them, and the backticks put that list on the command line aftergrep -L copyright, which searches those files and lists the subset of them that doesn’t contain “copyright”.