Reputation: 5077
How do I search a file containing $
using grep?
I've tried
grep "\$" file.txt
and it does not recognize the $
character to search for.
Upvotes: 1
Views: 1673
Reputation: 626950
As I posted in my comment,
grep "\\\$" file.txt
The first \\
is a literal \
for the regex engine, and the thrid \
is used to escape the dollar symbol.
A rule of thumb with matching a literal dollar symbol is:
$
(i.e. $$
)Some of it should work.
Upvotes: 2
Reputation: 21620
Please see this answer in another stack exchange forum. Basically you should try grep '\$'.
Upvotes: 2