replace > with new line character

<reward_data><date><datetime>071308000804</datetime></date>

I want the above data to be displayed as

<reward_data>
<date>
<datetime>071308000804</datetime>
</date>

How can i accomplish this.

I tried the below

tr "><" ">\n" < filename

> cat file9
<reward_data><date><datetime>071308000804</datetime></date>

> cat file9 | sed "s/></>~</g" | tr "~" "\n"
<reward_data>
<date>
<datetime>071308000804</datetime>
</date>

I had to do a substitution to ~ to then use the tr command to get the new line. By the way, I think the tr command only works with single characters - thus your initial problem.

Well if you really want tr try this:

tr -s '>' '\n' < filename | sed 's/$/>/'

tr works only on single characters not "><"

awk '{gsub("><",">\n<");print }' file

Hi,

Try this

sed 's/></>\[press Enter(newline)]
</g' filename

Regards,
Chella