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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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?
did you try the sed command?
ASKER
sorry ozo,
perl command is working perfectly.
It was my mistake that,i added char ">" before the command.
Thanks
perl command is working perfectly.
It was my mistake that,i added char ">" before the command.
Thanks
ASKER
Is it possible with sed command in a single line?
ASKER
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
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
another way to do it without the $1 would be
perl -pe 's#(?<=</Close>)#\n#gi' sourcefile.txt > targetfile.txt
ASKER
problem solved.
ASKER