You can use the --include
option with the grep
command to restrict the search to only .php files. Here’s how you can do it:
grep -r --include="*.php" "myipaddress" /var/www/vhosts/
This command will recursively search through all .php files in the /var/www/vhosts/
directory and its subdirectories for the IP address “myipaddress”. If it finds a match, it will print the filename and the line containing the match to the terminal.
Please note that you might need to use sudo
before the grep
command if the files require root permissions to read.