Append using SED/AWK

Hi friends,

I have a file with content SOME TEXT HERE

I want to append the string GREAT to Line 1 of my file such that the file content should be
GREAT
SOME TEXT HERE

I can do a cat for the string great and file >> newfile and then rename newfile name to file

But this does not put GREAT at Line1. It writes in one single line like GREAT SOME TEXT HERE.

Is there any better way to do this? May be using SED/AWK?

Also please show some pointers to SED/AWk tutorials I would like to start learning them.

Try:

awk 'NR==1{print "GREAT"; }NR ' file

Great! Thank you it works and can you please guide me to some good SED/AWK tutorials?

Awk...

Awk - A Tutorial and Introduction - by Bruce Barnett

Sed...

Sed - An Introduction and Tutorial

regards,

or

sed '1i GREAT' file

cheers,
Devaraj Takhellambam

Using sed: append one line in header of the file.
See the following example:

 cat file
SOME TEXT HERE

 sed  -i  '1{s/^/GREAT\n/}' file

 cat file
GREAT
SOME TEXT HERE