Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Expect - parse all occurrences of a pattern and store in a variable

$
0
0

I am trying to process multiple mac addresses from output of a program. Output is in below format -

Device B0:CA:68:CF:88:54 dev1
Device DC:16:B2:AE:FB:8F dev2
Device B0:CA:68:CF:88:11 dev3
Device DC:16:B2:AE:FB:22 dev4

I want to store mac addresses along with their names in a file And I want to store mac addresses in a variable and process further.

I am struggling with it in Expect. How to do it ? Please help

Below command works but only gives single Mac -

expect -re "Device.*(\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z]:\[0-9A-Z]\[0-9A-Z])"

Viewing all articles
Browse latest Browse all 157

Trending Articles