my dog learned polymorphism*
The moose likes Linux / UNIX and the fly likes SED Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "SED" Watch "SED" New topic
Author

SED

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1859
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
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SED