-3

I need to get a number string from between two special strings.

String : Build : 76.x-20161016_x_567.0 <br> GRN : <a href="http://toolserver.lab.net:9080/jenkins/job/test_prj/20/changes">109960</a>

Need to get the number (here 109960) between ">" and "</a>" How can I use sed for this.?

  • 2
    This is pretty straight forward. What did you try? – heemayl Oct 17 '16 at 12:02
  • String is <description>Build : 76.x-20161016_x_567.0 <br> GRN : <a href="http://toolserver.lab.net:9080/jenkins/job/test_prj/20/changes"&gt;809960&lt;/a&gt;</description>and I tried sed -e 's/\&gt\;(.*)\&lt\;/\1/'` but didnt help – tony Oct 17 '16 at 12:06
  • 2
    Please add your efforts to your question. – heemayl Oct 17 '16 at 12:10
  • Also your comment seems contradictory to your post in terms of what pattern is wrapping the number you want to extract: is it &gt;[NUMBER];/a&gt or >[number]</a> ? Please clarify and edit your post accordingly. – Valentin B. Oct 17 '16 at 14:14
0
$ string='Build : 76.x-20161016_x_567.0 <br> GRN : <a href="http://toolserver.lab.net:9080/jenkins/job/test_prj/20/changes">109960</a>'

$ echo $string | sed 's/^.*>\([0-9]*\)<\/a>.*$/\1/'
109960

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.