Linux Text Processing Cheat Sheet/Print line range with awk

Alternative line-range extraction using NR.

Section: Line Selection and Context

Print line range with awk

bash
bash
awk 'NR>=100 && NR<=120' file.txt
Explanation

Awk's `NR` variable tracks the current line number.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Line Selection and Context
Print a specific line range
Extract lines 100 through 120.
OpenIn sheetbashsame section
Show first 20 lines
Preview the top of a file.
OpenIn sheetbashsame section
Show last 50 lines
Read the end of a file.
OpenIn sheetbashsame section
Follow a log in real time
Watch new lines as they are appended.
OpenIn sheetbashsame section
Read from standard input
Many text tools consume stdin naturally.
OpenIn sheetbash1 tag match
Pipe file content into grep
Basic pipeline for filtering text from a file.