View Full Version : how to get first n lines of a file
March 9th, 2007, 04:04 AM
i have some huge text files.
But while I test and develop, I want some small files.
So I want a way to "cat" the first n-lines to another file.
There must be some nice linux command tools for this.
Thanks in advance
March 9th, 2007, 04:09 AM
Check out head.
March 9th, 2007, 04:14 AM
this is excatly what I needed :)
March 9th, 2007, 04:27 AM
You're welcome. For future reference, the apropos command is helpful when you know what you want to do, are sure some command does it, but aren't sure which one. Try this:
apropos first lines
And don't forget the forum search.
March 9th, 2007, 04:27 PM
You could also do
sed -n 1,Np file.txt > newfile
That will put the first N lines in newfile.
March 9th, 2007, 04:28 PM
head is a lot faster than sed, so... I am just babbling, I guess.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.