-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?

pLumo
  • 22,231
  • 2
  • 41
  • 66
rajesh
  • 1
  • 1
  • 1

2 Answers2

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
pLumo
  • 22,231
  • 2
  • 41
  • 66
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>.

RalfFriedl
  • 8,816
  • 6
  • 23
  • 34