Mobile app version of vmapp.org
Login or Join
Bethany197

: How to grep (or find) on cPanel? How can I search for a specific string (function name or a variable name) in my files which are in various directories under cPanel file manager? I have been

@Bethany197

Posted in: #Cpanel #FileManager #Search #SiteDeployment

How can I search for a specific string (function name or a variable name) in my files which are in various directories under cPanel file manager?

I have been using a library directory and functions on that directory are used in various apps and pages. Now, I am in a situation to change something in the library file, for which I need to know the impact on files which use this library file functions.

How to search / find / grep through the files hosted?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Bethany197

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sims2060225

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.


Login to yourdomain/cpanel
Go to File Manager - elect to go to www/public_html
Create new file with .php extension - I created ecebeb.php - then edit it.
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.";
?>
Now, open a new browser tab/window and browse to the URL like yourdomain/ecebeb.php

10% popularity Vote Up Vote Down


 

@Jessie594

AFAIK, it’s impossible. You must write a PHP/Perl/Python/whatever script and run it on your server to get the list of files and grep through it.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme