简体   繁体   中英

How to search through directory for a string

I've came up with a script to find a certain string in a directory, but when I do it, it only shows the first string and not the others... how would I go about it showing all of the other strings?

The code,

$result = exec("grep -r admin@admin.com /var/www/html/files/*");
echo $result;

Thank you!

Try exec("grep -r admin@admin.com /var/www/html/files/*", $result); . According to PHP manual exec return the last line from the result of the command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM