• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SED

 
Rahul Mahindrakar
Ranch Hand
Posts: 1868
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Over here

http://www.theunixschool.com/2012/11/howto-retrieve-extract-tag-value-xml-linux.html

Is the command

sed -n '/CustName/{s/.*<CustName>//;s/<\/CustName.*//;p;}' cust.xml

Can someone please tell me how this works?
 
Henry Wong
author
Marshal
Pie
Posts: 21007
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul Mahindrakar wrote:Over here

http://www.theunixschool.com/2012/11/howto-retrieve-extract-tag-value-xml-linux.html

Is the command

sed -n '/CustName/{s/.*<CustName>//;s/<\/CustName.*//;p;}' cust.xml

Can someone please tell me how this works?



There are whole books on sed, so there is no way a single post is going to go into had sed works... but as for what the command is doing. It is looking for lines with CustName -- and is (a) removing <CustName> and (b) removing /CustName followed by any characters to the end of line.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic