Extract first 100 lines from a file in UNIX

I was tasked to get first 100 lines of records from a database dump. While searching big brother G, I found the solution here:- how to extract a range of lines from a file provided by zazzybob.

Here’s the solutions:-

You could also pipe though sed to extract the range – e.g.
blah | sed -n ‘1,1000p’ | blah
to extract the first 1000 lines of the file

How I uses it:-

cat file.unl | sed -n ‘1,100p’ > out100.unl


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.