Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-27-2011, 10:10 PM   #1
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie stretch
Posts: 1,480

Rep: Reputation: 86
head -n -1 (sed -n -e '1,$-1p' is incorrect) sed question, as stupid as it could be.


Is it possible to write "head -n -1" equivalent in sed? (or anything simpler)

I need some tiny script to write all but last one line. I was confident that gnu sed would work, 'sed -n -e '1,$-1p' which did not. It took almost an hour for me to get to 'head -n -1'

Simply, I am curious if it is possible.

Happy Penguins!
Old 12-27-2011, 10:18 PM   #2
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
sed '$d'
Seems to be what you're after, if I understand that is.


busybox, cat, coreutils, head, sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sed 's/Tb05.5K5.100/Tb229/' alone but doesn't work in sed file w/ other expressions Radha.jg Programming 6 03-03-2011 08:59 AM
sed: how to change MAC address string with sed cold Linux - Software 5 08-02-2010 08:43 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 01:34 AM
sed question lazyuser Programming 4 02-11-2005 07:11 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM

All times are GMT -5. The time now is 10:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration