我期望脚本的输出如下所示:
我想提取数组或列表中的所有单词,例如 Gi/02/12 等。
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
答案1
尝试grep -o
使用这个最小模式:
grep -o '..././..' file