Reputation: 323
How could I show names of all PHP files in the current folder that contain the string "Form.new" in a Linux system?
I have tried grep "Form.new" .
Upvotes: 0
Views: 197
Reputation: 433
Assuming that your PHP files have a .php
extension, the following will do the trick:
grep "Form\.new" *.php
Like @LaughDonor mentioned, it's good practise to escape the dot; otherwise, dot is interpreted as “any character” by grep. "Form.new" also matches "Form_new", "Form-new", "Form:new", "FormAnew", etc.
Upvotes: 0
Reputation: 42984
You need to search recursive or using*
instead of .
, depending of whether you want to search only file right inside that directory or also in deeper levels. So:
grep -r "Form\.new" .
or
grep "Form\.new" *
Upvotes: 1