Adding New empty line in a file

Hi,

I am new to Sed /awk commands. using that i want to add new empty line after every line in a file by leaving first three lines. So, can any one help me out how to achieve this.

Example:
---------
Input Filename: file1.txt

Input Data:
--------Report--------
Date:20-10-03
-----------------------
101,xyz,400
102,abc,500
103,ghj,600
104,gfhj,700

expect results in output file:
--------------------------
Output Filename: fileout.txt

Output file data:
--------Report--------
Date:20-10-03
-----------------------
101,xyz,400

102,abc,500

103,ghj,600

104,gfhj,700

please help me how to achieve this using sed or awk commands. Thanks for your help in advance.

Thanks in advance
G.K

awk 'NR>3{ORS="\n\n"}1' infile

or

awk 'NR>3{$0=$0"\n"}1' infile

---------- Post updated at 09:25 PM ---------- Previous update was at 09:24 PM ----------

use

nawk

instead of

awk

if you run on solaris plateform

---------- Post updated at 09:48 PM ---------- Previous update was at 09:25 PM ----------

or

sed '4,${p;s/.*//;}' infile

---------- Post updated at 09:49 PM ---------- Previous update was at 09:48 PM ----------

I tested it on FreeBSD (the last semicolon may be removed depending on what you run)

 sed -n '4,$G;p;' infile

will do the job.

@sk1418 :

yup ! it does :slight_smile:

Sed command gives the expected results....

Thanks very much to every one for the reply....

Thanks
G.K.K