LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   head -n -1 (sed -n -e '1,$-1p' is incorrect) sed question, as stupid as it could be. (https://www.linuxquestions.org/questions/programming-9/head-n-1-sed-n-e-1-%24-1p-is-incorrect-sed-question-as-stupid-as-it-could-be-920808/)

kaz2100 12-27-2011 09:10 PM

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

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

Situation:
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!

Telengard 12-27-2011 09:18 PM

Code:

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


All times are GMT -5. The time now is 11:07 PM.