grep match only lines in a specified range
grep, linux
Solution
sed -n '1024,2048{/error/{=;p}}' | paste - -
Here `/error/` is a pattern to match and `=` prints the line number.
Problem
Is it possible to use grep to match only lines with numbers in a pre-specified range? For instance I want to list all lines with numbers in the range `[1024, 2048]` of a log that contain the word 'error'. I would like to keep the '-n' functionality i.e. have the number of the matched line in the file.