Sunday, April 13, 2008

extract a range of lines from a file

problem:
You want to extract a range of lines from a file

solution:
sed comes to the rescue here! the following would print the line range from filename to stdout
sed -n '5,8p;8q' filename
5 = from line 5, including 5
8p = to line 8 including 8
8q = stop processing and quit

citation:
http://linuxactivist.blogspot.com

No comments: