I have a string which can contain 2 or more integers. I am trying to extract only the 2nd integer but the following code is printing all occurences.
#!/bin/bash
TEST_STRING=$(echo "207 - 11 (INTERRUPT_NAME) 0xffffffff:0xffffffff")
ERROR_COUNT=$(echo $TEST_STRING | grep -o -E '[0-9]+')
echo $ERROR_COUNT
The output is:
207 11 0 0
Basically I would like ERROR_COUNT to be 11 for the given TEST_STRING.
'[0-9]{2}'