How to print specific lines from large text files.

posted May 2, 2012, 4:15 PM by Sachchida Ojha   [ updated May 22, 2013, 9:10 AM ]
I have been asked to dump lines 50001 to 50100 from a text file size 20GB having 50 million lines. What are the various option?

1. sed -e '1,N d; M q' ---> This command will print the line from N+1 to M.

sed -e '1,50000 d; 50100 q'

2. sed -n '50000,50100p' file_name

3. awk 'FNR>50000 && FNR<=50100' file





Comments