node ninja
node ninja

Reputation: 32986

How to find this string in multiple files with grep?

I'm trying to use grep to find the string "init()" in all the files that end in .js in a directory.

I tried this

grep "init()" *.js

but it didn't work. Why not? What's the correct way to do this?

Upvotes: 0

Views: 797

Answers (1)

Supr
Supr

Reputation: 19012

Try escaping the parentheses: grep "init\(\)" *.js

It is actually a regular expression, where ( and ) are special characters.

Upvotes: 4

Related Questions