Search Within Files on Your Server

Just learned how to do this… freakin epic. It allows you to search within files on your server. A lot of times I will need to search thousands of files for websites written by other people for a single line of code for ID’s or Tags… e.g. I was just looking for “portfolio_title” so I could modify the php for my portfolio page.

First you need to SSH into your server as root via something like terminal for OSX, or telnet for PC

ssh root@67.55.108.167 (or whatever your server IP is)

After you enter your password, you need to run this command

find . -exec grep -l "portfolio_title" {} \; | xargs grep "portfolio_title"

If you’re trying to search under ALL your different accounts under root, you can run this instead. This will search under every account which contains the directory public_html/wp-content

find /home/*/public_html/wp-content/ -exec grep -l "portfolio_title" {} \; | xargs grep "portfolio_title"

Alternatively, you can replace * with your specific account name if you dont want to use a wildcard