0

netstat -s gives output like below

Tcp: 12345 active connections openings 34345345 passive connection openings 3434 failed connection attempts 54545 connection resets received 5 connections established 65565 segments received 575575 segments send out 57 segments retransmited 10 bad segments received. 12121 resets sent.

From above output, I want to get number of segments received and segments send out in two separate variable.

I just started with shell, I have following code snippet, but not sure how can I proceed with regex

echo "${OUTPUT}"


re="(\d+) segments send out'"

if [[ ${OUTPUT} =~ $re ]]; then // not sure here how to extract number`



2

0

Browse other questions tagged or ask your own question.