Skip to content
Advertisement

Get string between two regex

I have a string that is like that(comes from a curl command’s body): The server returns an xml

JavaScript

Sometimes this strong can become or some other error:

JavaScript

I’m wonder what would be the best way to grep the status code 200 and if it is not 200. Give an error like “Status code is 500 with error: java.lang.IllegalStateException: Archive not valid

So far I have some improvement:

sed -n “s|<status code=”200″>(.*)|1|p” test.log

But how do I get the status code too with sed

Advertisement

Answer

To get attribute code of node status, just:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement