Search code examples
ag

How can I escape a single quote in ag (without using double quotes)


How can I escape a single quote in ag when searching for an expression like this one?

ag ''react-redux''

I'm aware that "'react-redux'" is one solution in this scenario, but I'd like a solution that lets me use single quotes. That way I don't have to worry about the complex escape sequences required by $, %, etc. when using double quotes.


Solution

  • you can use \x27 to represent single quotes. (\x27 is just the ascii code for single quotes) thus, you can use:

    ag '\x27react-redux\x27'
    

    ref: How to escape single quote in sed? --stackoverflow