listing directory with "grep"

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all,
I'm using the readdir function to list in a php page all the files into
my directory,

Is there a function that permit me to list all file grepping the "rom"

I've got:

if ($handle = opendir('/opt/dir')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
         echo "$file<br>";

in shell I would like to have:

ls /opt/dir | grep -i rom


Re: listing directory with "grep"

Davide wrote:
Quoted text here. Click to load it

Take a look at the glob() function <


Site Timeline