This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SED

 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • 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: 21504
84
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic