How to make a new line of the file?

Hi,

I have a file (newfile.txt) with the contents below:

This is a new file. This is a new file. This is a new file. This is a new file.

How could I make a new line of the file as below?

This is a new file. 
This is a new file. 
This is a new file. 
This is a new file.

When there is a keyword "This is" it will be making it a new line.
I know awk can do this, appreciate if anyone can help.

Thanks!

Probably not perfect, but:

$ awk '{gsub(/  *This is/, "\nThis is", $0)}1' file
This is a new file.
This is a new file.
This is a new file.
This is a new file.
sed s/T/\nT/g /path/to/file

Should work but is untested.

This just add "n" before every T, so not working. What if word is starting with Test.
This should not be triggered, only "This is"

Well actualy, focusing on "This" is wrong either..
So it'll should be better to use any capital letter as indicator for a new line..
As you most surley dont have a file filled with "This is a new line." strings...

sed s/"\.\ "/"\.\n"/g  /path/to/file

However, if there is a space after a 'dot', it makes a new linebreak after it while cutting the trailing (1) space.

hth

sed -r 's/\. +([A-Z])/\.\n\1/g' file
When there is a keyword "This is" it will be making it a new line.

This is some of the request.

In that case it should have been posted in Home- & Coursework
To me at least, it very much looks like that under this conditions.

Try:

sed 's/This is/\
&/g; s/^\n//' file

or with seds that can use a \n in the replacement part:

sed 's/This is/\n&/g; s/^\n//' file

hi,

how should i add an empty line to my file,
example, below myfile.txt
"

this is first line
this is second line
this is third line

"

I would like the file formated as below by adding an empty line to each existing line:
"

this is first line

this is second line

this is third line

"
Thanks

One way: (needs gwak)

awk 1 ORS="\n\n"
this is first line

this is second line

this is third line

Other options

awk '{print $0 "\n"}'
awk '1; { print "" }'

That should work with any awk, not just gawk..

Ahh, thanks. I know there are limitation to number of characters in RS, and thought it was the same for ORS.