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

Share, Pillage, Plunder, and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Google Bookmarks
  • Fark
  • Propeller
  • Reddit
  • StumbleUpon
  • Yahoo! Buzz
  • Twitter
  • Diigo
  • email
  • NewsVine

Comment Rules:  Links are +follow, so you will get backlinks to your website when you post here; keep in mind however that comments are moderated and I won't approve any spam, or ham, or even turkey. Please do not put your URL in the comment box, and always take your shoes off at the door. Got it? Good.



Leave a Reply

Comment Rules:  Links are +follow, so you will get backlinks to your website when you post here; keep in mind however that comments are moderated and I won't approve any spam, or ham, or even turkey. Please do not put your URL in the comment box, and always take your shoes off at the door. Got it? Good.