3

I need to search a large amount of files on my hosting that runs cPanel.

They don't have SSH, is there a way I can run grep in any other way to search my files for a certain piece of text?

TPLinks
  • 133
  • 2

2 Answers2

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

Change to suit your required grep search.

Save as grep.php. Then upload to root directory and visit the URL

http://Your Site/grep.php
X Tian
  • 10,413
  • 2
  • 33
  • 48
Melik
  • 56
  • 1
0

Yes you can use grep command without shell. First you need to check function is enable shell_exec enable in php.ini then you can use.

TPS
  • 2,483
  • 5
  • 27
  • 45