Awk - :
$ awk 'NR>=1024 && NR<=2048 && /error/ {print NR,$0}' file
The Awkvariable NRcontains the current line number, and $0contains the line.
The benefits of using it Awkare that you can easily change the output to display, but you want to use it. For example, to separate a line number from a colon line followed by a TAB:
$ awk 'NR>=1024 && NR<=2048 && /error/ {print NR,$0}' OFS=':\t' file
source
share