Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

i have expect script whose output looks like :

I would like to extract all words like Gi/02/12 etc in an array or a list.

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
121  Voice_C-LAN                      active    Gi1/0/12, Gi1/0/13, Gi1/0/14, Gi1/0/15, Gi1/0/16, Gi1/0/17, Gi1/0/18, Gi1/0/19, Gi1/0/20, Gi1/0/21, Gi1/0/22
                                                Gi1/0/23, Fa2/0/13, Fa2/0/14, Fa2/0/15, Fa2/0/16, Fa2/0/17, Fa2/0/18, Fa2/0/19, Fa2/0/20, Fa2/0/21, Fa2/0/22
                                                Fa2/0/23, Fa2/0/24, Gi2/0/1

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
share|improve this question
1  
Another approach, in case you're not aware of it, is—assuming this is coming from a switch or similar—to use the SNMP command-line tools. May be easier, depending on what exactly you're doing. –  derobert Mar 12 '13 at 16:20
    
right i am am completely unaware of it –  munish Mar 13 '13 at 6:57
add comment

1 Answer

up vote 3 down vote accepted

Try grep -o with this minimal pattern:

grep -o '..././..' file
share|improve this answer
    
thanks it works –  munish Mar 12 '13 at 13:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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