Return to Snippet

Revision: 21313
at November 17, 2010 06:40 by blackthorne


Updated Code
Let's say you want to get all lines from 4 to 10 in the file /etc/passwd: 
sed -n '4,10p' /etc/passwd

Alternative:
head -n 10 /etc/passwd | tail -n 6
or
FIRST_LINE=4; LAST_LINE=10; head -n $LAST_LINE /etc/passwd |tail -n `echo "$LAST_LINE - $FIRST_LINE"|bc`

Revision: 21312
at December 10, 2009 08:45 by blackthorne


Initial Code
Let's say you want to get all lines from 4 to 10 in the file /etc/passwd: 
sed -n '4,10p' /etc/passwd

Initial URL


Initial Description


Initial Title
Display a range of lines in a specified file

Initial Tags


Initial Language
Bash