How to grep (or find) on cPanel?

I can understand the frustration when you don't have access to SSH. Below is a simple PHP script that you save in a file in the root folder from where you want to start your search. For example, I wanted to find all files that have the HEX color code string ecebeb under the ../public_html (or the www) folder. Retracing the steps here.

  1. Login to yourdomain/cpanel
  2. Go to File Manager - elect to go to www/public_html
  3. Create new file with .php extension - I created ecebeb.php - then edit it.
  4. Copy below 6 lines script, paste it in the ecebeb.php edit window and save the file.

    <?php
    $command = "grep -ri 'ecebeb' ./*";
    $output = shell_exec($command);
    echo "$output";
    echo "Grep job over.";
    ?>

  5. Now, open a new browser tab/window and browse to the URL like yourdomain/ecebeb.php