-3

I have file filestore.xml from which I need to extract /local/armdata/data/filestore1, /local/armdata/data/filestore2.

grep binariesDir filestore.xml <binariesDir>/local/armdata/data/filestore1</binariesDir> <binariesDir>/local/armdata/data/filestore2</binariesDir> 

Is there any way to do this?

2
  • grep binariesDir filestore.xml <binariesDir>/local/armdata/data/filestore1</binariesDir> <binariesDir>/local/armdata/data/filestore2</binariesDir>
    – rajesh
    CommentedOct 23, 2018 at 6:20
  • Please don't add information in the comments, edit the question, especially if it needs formatting.CommentedOct 23, 2018 at 6:37

2 Answers 2

2

Using XMLStarlet:

xml sel -t -v '//binariesDir' filestore.xml 

on Ubuntu with xmlstarlet package installed, I need to use this:

xmlstarlet sel -t -v '//binariesDir' filestore.xml 
    1

    You can use sed.

    sed -nre 's:^.*<binariesDir>(.*)</binariesDir>.*$:\1:p' filestore.xml 

    This handles both the searching for binariesDir and extracting the value between <binariesDir> and </binariesDir>.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.