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 copyright `grep -l base64_decode *`
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 after grep -L copyright
, which searches those files and lists the subset of them that doesn't contain "copyright".