problem in replacing asterisk in sed

Hi all,

Sed is the one which always trobules me :frowning:

here is my input :

 
*** it industry need to be evolved *** in the world and hope so *** to be dream

the output i am expecting is :

 
*** it industry need to be evolved
*** in the world and hope so 
*** to be dream

here is what i have tried

TESTING>sed '/ \*\*\* / i\
>
> ' ravi_test.txt

here one line is inserted before the first "***" ( ofcourse it does not follwed spaces as specified in the condition.

One more doubt : when using "tr" to replace the "\n" with " " , further i can't use this output in a filter to sed as sed expects "\n" at the end to consider it as a line ?.. any clue on how to use "tr" in this case( have to retain the last "\n")

thanks and regards
Panyam

Something like this?

sed 's/ \*\*\*/\
\*\*\*/g'

Regards

if you have Python

#!/usr/bin/env python
for line in open("file"):
    line=line.strip().split("***")
    for i in line:
        if i!="" : print "***"+i

output

# ./test.py
*** it industry need to be evolved
*** in the world and hope so
*** to be dream

With awk:

awk '{gsub(" \*\*\*","\n***")}1'

Regards

Thanks Franklin and ghostdog74. It's worked fine.