wood burning stoves 2.0*
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: 1845
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: 18510
    
  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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: SED
 
Similar Threads
Adding a variable value to the text file
[SED]How to replace a line with newone if a pattern matches
Replacing a word in a text file
Inserting newline character
Simple question