Skip to content

Instantly share code, notes, and snippets.

@sumitasok
Last active May 17, 2018 12:54
Show Gist options
  • Save sumitasok/f516a29fed280f8753d89b98877ecf6c to your computer and use it in GitHub Desktop.
Save sumitasok/f516a29fed280f8753d89b98877ecf6c to your computer and use it in GitHub Desktop.
# * 100,000,000-line file generated by seq 100000000 > test.in
# * Reading lines 50,000,000-50,000,010
# * Tests in no particular order
# * real time as reported by bash's builtin time
# https://unix.stackexchange.com/questions/47407/cat-line-x-to-line-y-on-a-huge-file
awk 'NR >= 57890000 && NR <= 57890010' /path/to/file
awk 'NR < 57890000 { next } { print } NR == 57890010 { exit }' /path/to/file
tail -n+50000000 test.in | head -n10
sed -n '50000000,50000010p;57890010q' test.in
head -n50000010 test.in | tail -n10
sed -n '50000000,50000010p' test.in
tail -n50000001 test.in | head -n10
ed -s test.in <<<"50000000,50000010p"
awk 'NR<57890000{next}1;NR==57890010{exit}' test.in
awk 'NR >= 57890000 && NR <= 57890010' test.in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment