Joelio
Joelio

Reputation: 4691

search for string in vi

I want to search for this:

 SELECT * FROM `influencers` WHERE (author_name =

within a log file using vi, I cant figure out how to properly escape this, I have tried:

 SELECT * FROM \`influencers\` WHERE \(author_name =

And several similar versions, but no luck

Upvotes: 0

Views: 177

Answers (2)

Klox
Klox

Reputation: 966

This should work:

SELECT \* FROM `influencers` WHERE [(]author_name =

EDIT: Seeing Keith's answer, he's right. My square brackets are unnecessary. But I'll leave my answer to make a point: whenever I have regex problems, wrapping questionable characters in square brackets is often a quick fix (and doesn't hurt).

Upvotes: 0

Keith Thompson
Keith Thompson

Reputation: 263627

In vim, the only character you need to escape is the *:

/SELECT \* FROM `influencers` WHERE (author_name =

If you're using a different vi variant than vim, you'll need to tell us what you're using.

Upvotes: 1

Related Questions