[COLOR="#000000"][COLOR="#0000BB"][/COLOR][COLOR="#007700"][/COLOR][/COLOR]
[COLOR="#000000"][COLOR="#0000BB"]$searchthis[/COLOR][COLOR="#007700"]=[/COLOR][COLOR="#DD0000"]"user"[/COLOR][COLOR="#007700"];[/COLOR][COLOR="#0000BB"]$matches[/COLOR][COLOR="#007700"]= array();[/COLOR][COLOR="#0000BB"]$dir[/COLOR][COLOR="#007700"]=[/COLOR][COLOR="#DD0000"]'logs/'[/COLOR][COLOR="#007700"];foreach([/COLOR][COLOR="#0000BB"]glob[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$dir[/COLOR][COLOR="#007700"].[/COLOR][COLOR="#DD0000"]'*.txt'[/COLOR][COLOR="#007700"]) as[/COLOR][COLOR="#0000BB"]$filename[/COLOR][COLOR="#007700"]) {[/COLOR][COLOR="#0000BB"]$handle[/COLOR][COLOR="#007700"]= @[/COLOR][COLOR="#0000BB"]fopen[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$filename[/COLOR][COLOR="#007700"],[/COLOR][COLOR="#DD0000"]"r"[/COLOR][COLOR="#007700"]); if ([/COLOR][COLOR="#0000BB"]$handle[/COLOR][COLOR="#007700"]) { while (![/COLOR][COLOR="#0000BB"]feof[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$handle[/COLOR][COLOR="#007700"])) {[/COLOR][COLOR="#0000BB"]$buffer[/COLOR][COLOR="#007700"]=[/COLOR][COLOR="#0000BB"]fgets[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$handle[/COLOR][COLOR="#007700"]); if([/COLOR][COLOR="#0000BB"]strpos[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$buffer[/COLOR][COLOR="#007700"],[/COLOR][COLOR="#0000BB"]$searchthis[/COLOR][COLOR="#007700"]) !==[/COLOR][COLOR="#0000BB"]FALSE[/COLOR][COLOR="#007700"])[/COLOR][COLOR="#0000BB"]$matches[/COLOR][COLOR="#007700"][] =[/COLOR][COLOR="#0000BB"]$filename[/COLOR][COLOR="#007700"].[/COLOR][COLOR="#DD0000"]': '[/COLOR][COLOR="#007700"].[/COLOR][COLOR="#0000BB"]$buffer[/COLOR][COLOR="#007700"]; }[/COLOR][COLOR="#0000BB"]fclose[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$handle[/COLOR][COLOR="#007700"]); }}[/COLOR][COLOR="#0000BB"]print_r[/COLOR][COLOR="#007700"]([/COLOR][COLOR="#0000BB"]$matches[/COLOR][COLOR="#007700"]);[/COLOR][/COLOR]
import os search = "phrase" for fl in os.listdir("./"): if fl[-4:] == ".txt": for line in open(fl,"r"): if search in line: print(line)