Sometimes you try to find a piece of code, but you are not sure which of your files it is in. In this post we discuss a tool that can find a string of text in any of your online files.
To Linux users GREP is nothing new. It is a tool that sifts through your files and tells you which contain your search query and where. For example:
- Ask GREP to find ‘variable x’
- GREP tells you it is found in file a, b and c on line numbers 2, 10 and 5
You can see how this would be useful.
There is a php file that acts as a search engine for all files on your webserver. You basically upload it, and you can use that page to search all your files. For example:
- You are looking for the file that contains your database settings
- You input ‘database’
- PHP grep tells you all the files with this keyword in it and on what line the keyword is
The setup is really simple:
- Download PHP GREP here
- Upload it to your root folder through FTP of SFTP
- Go to yourdomain.com/php-grep.php
- Input your search word
You can now find any code inside any of your files.