Link to home
Start Free TrialLog in
Avatar of sunshine737
sunshine737

asked on

add new line after an xml tag

Hi,
I want to add a new line after a tag </Close>  in a file.

i tried the command.but not working
sed 's/</Close>/&\n\//g' sourcefile.txt  > targetfile.txt
Avatar of sunshine737
sunshine737

ASKER

Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i got the error when used perl command.
syntax error at -e line 1, next token ???
Execution of -e aborted due to compilation errors.

I want to add new line, after tag </Close>  in entire file.


Thanks
Are you sure you used the correct perl command?
did you try the sed command?
sorry ozo,
perl command is working perfectly.

It was my mistake that,i added char ">" before the command.

Thanks
Is it possible with sed command in a single line?
Hi Ozo,

The command you provided is removing the tag </Close>

I still need the tag </Close> , in addition to newline before the xml tag.

Can you please help me?

Thanks
did you include the $1 in the perl command, or the & in the sed command?
another way to do it without the $1 would be
perl -pe 's#(?<=</Close>)#\n#gi' sourcefile.txt  > targetfile.txt
problem solved.