I am trying to replace a line in my .xml file using a shell script (working on MAC OSX). Problem is: I want to change a tag <source-path>/Users/myouser</source-path>
to <source-path>/Users/otherUser</source-path>
I am having two problems:
1) How can I handle with "/" using sed? 2) Can I use regular expression?
Thanks
The simplest answers is to use a different delimiter in your expression, eg:
sed -e 's|/Users/myouser|/Users/otherUser|' file.xml
As to whether you can use regular expressions -- you're using sed
, so yes.
Standard disclaimer that modifying XML with sed is a fragile and error-prone approach.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.