I want to find the number of occurrences of XXX in my latex document that are not in the form of a command as \XXX. Therefore I am looking for occurrences that are not preceded by a backslash.
I tried the following:
grep -c -e '(?<!\)XXX' test.tex #result: grep: Unmatched ) or \)
grep -c -e '(?<!\\)XXX' test.tex #result: 0
grep -c -e "(?<!\\)XXX" test.tex #result: -bash: !\\: event not found
none of them work as intended. In fact I don't understand the last error message at all.
My test.tex contains only the following lines
%test.tex
XXX
\XXX
So the expected result is 1.
Any ideas?
Ps.: I am working in bash.