Timeline for Search and replace specific tag value in XML file with sed command
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 11, 2018 at 9:16 | comment | added | user3611640 | @kusalananda...i got the solution using sed command, also its working as expected. sed -i '/<param-name>com.sun.faces.numberOfViewsInSession<\/param-name>/{n;s/<param-value>3<\/param-value>/<param-value>25<\/param-value>/}' web.xml | |
| Dec 10, 2018 at 14:08 | comment | added | Kusalananda♦ |
@user3611640 I'm not going to give you a sed answer. Structured document formats like XML (or JSON or even some forms of CSV) require parsing by a real parser, not a line-oriented text tool like sed or awk or any of the other standard Unix text manipulation tools. You could also parse the XML in Python or Perl with some XML module, obviously.
|
|
| Dec 10, 2018 at 14:05 | comment | added | user3611640 | @kusalananda....i am not sure i will be able to install xmlstarlet at client box, any other approach is there to achieve this..like using xml or sed command. | |
| Dec 10, 2018 at 14:00 | comment | added | Kusalananda♦ |
@user3611640 Well, yes. It relies on having the xmlstarlet tool installed. On some Unices, it may be installed as just xml, on others you will have to install it from the packaging system. It's available on Linux and BSD, at least.
|
|
| Dec 10, 2018 at 13:57 | comment | added | user3611640 | thank you so much for the solution, sorry but i am new to shell/bash script...i tried your command, i am getting below error: xmlstarlet: command not found | |
| Dec 10, 2018 at 13:52 | history | answered | Kusalananda♦ | CC BY-SA 4.0 |