new line at last line

Hay hay all,

I wish to add a new blank line to the end of a file using sed. I've tried:

sed '/$/{G}' /tmp/$$.ace >>! /elsewhere/file.dat

but it fails. I do not think that I am matching the last line right? So how do I do it?

see this thread

dude, that failed to aid me in my answer. c'mon it's one line, someone must know.

try this:

sed '$a\
' filename > new_filename

You have to type this on two lines - exactly as I have. Works in ksh. Just tried it for you.

The $ is for the last line - the 'a' is for append - then the \ and newline is to add a blank line.

the catch is that i'm using c-shell (tcsh)

Then use this

sed '$a\\
' filename > new_filename

Double \\ required. Again - I tried in this shell.

Why do people find the need to do NO reading these days? I mean comeon is this what todays youth brings? a bunch of ppl who think they can just ask for an answer and they shall recieve?

Peters 1st reply to your post refering you to something that was ALREADY asked was dead on. if you bothered to read it you would see it.

you asked a question we provided you w/ an answer. You must translate it to how you want to use it. This is called learning.

and why would you use sed to add a blank line at the end of a file? just echo a blank line at the end. its much easier.

echo >> /tmp/your_file

Problem solved.

And I truly agree with Optimus that more effort could be put into finding one's own solution, but on the other hand, some people don't care why something works - they think they'll never use it again.

Oh well - job security, I suppose.

hey, I did try. I looked in the info file. I looked in the man file. I looked and READ Peter's post and I DID apply it to my sit'ion. However, it was the syntax of the double slash that error'd me (eg $a\\ ). Sorry - But this script @#$% is a mix of garbage. I'll stick to C++ and .NET. And I'll leave it there for now. Soory again. Thanks Pete!

"echo " is the best solution to such problem
you don't need anything more after that

and buddy, take your words back. this is not @#$%. and neither garbage. if you don't know how to use it, or don't have the patience, thats another thing.

Um, folks we try to watch our language in these forums.

Maybe in defence of gsjf.... sometimes I'll ask for certain method because I'll want to learn it that way....not that it's necessarily the best way...but one that maybe is requried or forms part of a bigger picture.

On the "$%^#&^%$ comments" that I see was censored (of course I'm curious now..) I think C++ is a bit of that myself because I don't know it..... I'm sure you'd jump to its defense too!