I have very long log files, is it possible to ask grep to only search the first 10 lines?
The output of head -10 file can be piped to grep in order to accomplish this:
head -10 file
grep
head -10 file | grep …
Using Perl:
perl -ne 'last if $. > 10; print if /pattern/' file