I want to know which files have the string $Id$
.
grep \$Id\$ my_dir/mylist_of_files
returns 0 occurrences.
I discovered that I have to use
grep \$Id$ my_dir/mylist_of_files
Then I see that the $Id
is colored in the output, i.e. it has been matched.
How could I match the second $
and why doesn't \$Id\$
work.
It doesn't matter if the second $
is the last character or not.
I use grep
2.9.
Before posting my question, I used google...
To search for a $ (dollar sign) in the file named test2, enter:
grep \\$ test2
The \\ (double backslash) characters are necessary in order to force the shell to pass a \$ (single backslash, dollar sign) to the grep command. The \ (single backslash) character tells the grep command to treat the following character (in this example the $) as a literal character rather than an expression character. Use the fgrep command to avoid the necessity of using escape characters such as the backslash.
but I don't understand why grep \$Id
works and why grep \\$Id\\$
doesn't.
I'm a little bit confused...
grep -F '$Id$'
. – jfg956 Feb 18 '12 at 11:17grep '$Id\$' ...
andgrep \$Id\\$ ...
work – nitsas Jan 29 '16 at 10:15$
with a preceding$
:grep '$$Id\$$'
. http://stackoverflow.com/a/2382810/2097284 – Camille Goudeseune Apr 04 '17 at 15:58