When I write
$ grep \$
then whatever I type on terminal, is matched and printed on terminal.
How is \$ being interpreted?
|
When I write
then whatever I type on terminal, is matched and printed on terminal. | ||||
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
The shell is interpreting the If you want to match an actual
In the former, the shell interprets As to your question as to why
along with many others. When you want to match a literla character that's normally treated as a special character, you need to escape it so that | |||||||||||
feedback
|
|
The shell first expands any escape sequences before passing the arguments to the program, so it interprets the | |||||||
feedback
|
|
It's being interpreted as the end-of-line metacharacter. If you want to match an actual dollar sign, do
or
| |||
|
feedback
|
|
or
will match every string, so anything you type is echoed back. Try
Now, only strings whose last character is | |||
|
feedback
|
|
you can save the trouble of escaping if you want to search for a literal
| |||
|
feedback
|