Get a range on line with sed (first two)

sed -n '1,2p;3q' file
Get the two first lines of a file and quit.
Sample Output
first-line
second-line

1
By: bugmenot
2021-07-16 07:29:15

What Others Think

Glad you bring this useful information, thanks a lot and you can let me share your article with others. taming io
eirawalker · 1 week and 4 days ago
Custom packaging Life is a journey, you don’t care about the destination, you care about the scenery along the way and the mood of seeing the scenery.
rhtdbgzv · 1 week and 3 days ago
https://www.icheckmovies.com https://www.icheckmovies.com/login/
BarbaraMJennette · 1 week and 1 day ago
Taxation Solution Manuals are available for instant download with no waiting time on Speedy Grade. Get top grades at ease with our assistance.
kennethparker · 1 week and 1 day ago
How can you get the first lines of a file? Do you have any idea about it? If no, then please try using this code. I have used this and I am so glad to say that it worked for me at the very first attempt. Go for it without my doubt. cbd oil for sleep
charlly · 1 week and 1 day ago
We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. fanyij.yoka-yoka.jp/index_2.html
hiknigarde · 5 days ago
You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. Buy big chief carts https://goowonderlandd.com/
mohsinkhatri · 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: