Hi Team,
I have a file with the following patterns:
==> xyz_Server_Started_with_Errors <==
errors.
==> abc_Server_Started_with_Errors <==
errors
==> reds_Server_Started_with_Errors <==
errorss
I want them in this format:
===================================================
==> xyz_Server_Started_with_Errors <==
===================================================
errors
===================================================
==> abc_Server_Started_with_Errors <==
==================================================
errors
==================================================
==> reds_Server_Started_with_Errors <==
==================================================
errorss
Thanks for the help
sed -i '/*Started_with_Errors/a =========================' one.txt > two.txt
But this doesnt seem to work
anbu23
4
sed '/Started_with_Errors/{s/^/===================================================\
/;s/$/\
===================================================/;}' one.txt > two.txt
1 Like
Can you please quickly explain?
anbu23
6
If a line contains pattern /Started_with_Errors/, then perform two substitution.
- Add "=======...\n" at the beginning of line containing pattern /Started_with_Errors/
s/^/===================================================\
/
- Add "\n=======..." at the end of the line containing pattern /Started_with_Errors/
s/$/\
===================================================/
---------- Post updated at 04:10 AM ---------- Previous update was at 03:37 AM ----------
sed '/Started_with_Errors/{ i\
===================================================
a\
===================================================
}' one.txt > two.txt