Trying to write a comand that prints these of its parameters, which correspond toregular files containing text main() in any of its first 10 lines.What i should you to scan all files, and look for 10 first lines?
Find 10 main() in first 10 lines in regular files
text processing;grep
You can avail yourself the GNU grep with it's Perl regexes also.This will output the line containing the string main() anywhere in the first 10 lines of the input file.The -z option allows the file to be slurped and treated as one big string (as long as it doesn't contain NUL characters)  on which grep is to operate. The -P enables the Perl mode of grep, -o shows you the matching portion, -h will hide the filename from being displayed alongside the matching line, and -l will list the filename only.In case you wanted both the filename and matching line:grep -HPoz  '\A(.*\n){0,9}\K[^\n]*main\(\)[^\n]*\n' file.txtonly matching line:grep -hPoz '\A(.*\n){0,9}\K[^\n]*main\(\)[^\n]*\n' file.txt(the -h being only necessary when there's more than one file)filename only:grep -Pozl '\A(.*\n){0,9}\K[^\n]*main\(\)[^\n]*\n' file.txtTo run over the current directory but without recursing: (ofc, the grep options need to supplied as per requirements as shown above)find . ! -name . -prune -type f \  -exec grep -HPoz '\A(.*\n){0,9}\K[^\n]*main\(\)[^\n]*\n' {} +