Linux Text Processing Cheat Sheet/Print a specific line range

Extract lines 100 through 120.

Section: Line Selection and Context

Print a specific line range

bash
bash
sed -n '100,120p' file.txt
Explanation

`sed -n` suppresses default output so only the requested range is printed.

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 line range with awk
Alternative line-range extraction using NR.
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
Trim leading whitespace
Remove spaces and tabs from the start of each line.
OpenIn sheetbash1 tag match
Trim trailing whitespace
Remove spaces and tabs from line endings.
OpenIn sheetbash1 tag match