Quotes when using grep?

后端 未结 4 555
南旧
南旧 2021-02-02 13:15

Grep acts differently depending on what kind of quotes I surround the regex with. I can\'t seem to get a clear understanding of why this is. Here is an example of the problem:

4条回答
  •  失恋的感觉
    2021-02-02 14:02

    I do not believe it is grep that is behaving differently, it is the shell. I'm assuming you are using bash

    http://www.faqs.org/docs/bashman/bashref_8.html

    Basically the quoted versions are behaving differently on the slash, depending on the quoting mechanism.

    Both of the quoted examples would have worked without the slash. For the first one, the shell would escape the ( and pass in just show( to the grep for the pattern.

提交回复
热议问题