1

I'm trying to get these values from the XML format below: USA GERMANY

<country name="USA" id="TEST1" password="123" /> <country name="GERMANY" id="TEST2" password="456" /> 

I was checking xmllint but I don't have --xpath installed and I just can't quite get the exact combination to get those values using grep.

2
  • 3
    grep is bad choice for such case Commented Mar 15, 2018 at 6:53
  • 1
    To reinforce the comment that grep is a bad choice: No matter what you do, it will totally fail as soon as the XML files get formatted bit differently, e.g. with line breaks. There are enough XML tools, or alternatives like sgrep available you don't need to rely on grep. Commented Mar 17, 2018 at 6:44

1 Answer 1

0

This works for me:

grep -P -o -e '(?<=name=").*?(?=")' 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.