I have a plain text document, which I want to compile inside LaTeX. However, sometimes it has the characters, \"#\", \"$\", \"%\", \"&\", and \"_\". To compile properly
I think your problem is that bash itself is handling those escapes.
\# that is already escaped. If that's not what you want, you might want to modify your patterns to check that there isn't a preceding \ already. grep "\\$" file.txt should do what you expect.