I rarely post a question because I’m trying to find a solution in the documentation or instructions, but this case was confusing to me.
I have a large file and using grep I search for the line I need. There is a need to use registry bypass.
So. I use php code:
$text = "тест";
$result_vul = trim(shell_exec('grep --ignore-case "'.$text.'" file.txt'));
echo $result_vul;
The file “test.txt” contains the lines:
ТЕСТ 123 Тест 456
There are no results when executed. However, if you use the command in the console, the result is:
webs@user:~/web$ cat test.txt
ТЕСТ 123
Тест 456
webs@user:~/web$ grep -i "тест" test.txt
ТЕСТ 123
Тест 456
Version GREP:
webs@user:~/web$ grep --version
grep (GNU grep) 3.8
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
I know that you can solve the problem in a similar way using file_get_contents and preg_match, but I’m interested in using the grep command, since the file is large.
Thanks for the help.
rorry_47 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.