Building on the other answer and the comment on it,
find . -type f -exec awk '/^!<symlink>/ {print FILENAME} {nextfile}' {} +
Because it uses -exec … +
, it will execute awk
as few times as possible
(based on the maximum argument list size).
If awk
finds a line that matches the regular expression
(i.e., the search string), it will print the filename.
(You don't need the backslash (\
) if you put the string in single quotes.)
Obviously, if you also want to see the content of the line, you can say
{print FILENAME; print}
or
{print FILENAME ": " $0}
And then, unconditionally, it advances to the next file;
so it effectively looks at only the first line of each file.
Note: nextfile
does not seem to be defined by POSIX;
it is probably only in GNU awk
.