Sed one liners to display line ranges

Display all lines from file except lines between two lines matching a pattern:

sed '/10\/02\/1992/,/01\/02\/2001/d' input.txt

Display lines between two lines matching a pattern:

sed -n '/10\/02\/1992/,/01\/02\/2001/p' input.txt

Display all lines from file, excluding a line range between 2 and 90:

sed 2,90d input.txt

Display only lines between line numbers 2 and 90:

sed -n 2,90p input.txt

Display line two:

sed -n 2p input.txt 

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).