How to grep in specific file type

I want to find a keyword in only php files, How can I do it in linux?

Tagged:

Answers

  • You can use find command.

    -type f :look into files only

    -name '*.php' :for file extension php only

    -exec :executing grep

    find ./ -type f -name '*.php' -exec grep -H --line-number --color "my keyword" {} \;
    


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!