I have very long log files, is it possible to ask grep to only search the first 10 lines?
Or use awk
for a single process without |
:
awk '/your_regexp/ && NR < 11' INPUTFILE
On each line, if your_regexp
matches, and the number of records (lines) is less than 11, it executes the default action (which is printing the input line).
Or use sed
:
sed -n '/your_regexp/p;10q' INPUTFILE
Checks your regexp and prints the line (-n
means don't print the input, which is otherwise the default), and quits right after the 10th line.