Print particular lines from a file using sed
Output the nth line of a file:
sed -n '20p;20q' < filename.ext
The '20p' part says print the 20th line. The '20q' part says stop searching the file at the 20th line - if you don't include this it will continue searching through the file until it reaches the end.
To output the nth to the mth lines:
sed -n '20,30p;30q' < filename.ext
Prints the 20th to the 30th lines.
Written by Stephen Cornelius
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#