Skip to content

Instantly share code, notes, and snippets.

@asaaki
Created October 6, 2014 14:52
Show Gist options
  • Save asaaki/9fd12a9421a72494eda2 to your computer and use it in GitHub Desktop.
Save asaaki/9fd12a9421a72494eda2 to your computer and use it in GitHub Desktop.
Grep a range of lines from a file
awk 'NR >= 100 && NR <= 300' file.in
sed -n '100,300p' file.in
# there are also solutions with head+tail, but it's not very intuitive for me
# example with bzipped files:
bzcat file.in | awk 'NR >= 100 && NR <= 300'
bzcat file.in | sed -n '100,300p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment