简体   繁体   English

提取名称和IP地址的shell脚本

[英]shell script to extract the name and IP address

Is there a way to use shell script to get only the name and net from the result as below: 有没有一种方法可以使用Shell脚本从结果中获取名称和网络,如下所示:

Result 结果

6cb7f14e-6466-4211-9a09-2b8e7ad92703 | name-erkoev4ja3rv                              | 2e3900ff36574cf9937d88223403da77 | ACTIVE | Running     | net0=10.1.1.2; ing-net=10.1.1.3; net=10.1.1.4; 

Expected Result 预期结果

name-erkoev4ja3rv: 10.1.1.4
$ input="6cb7f14e-6466-4211-9a09-2b8e7ad92703 | name-erkoev4ja3rv                              | 2e3900ff36574cf9937d88223403da77 | ACTIVE | Running     | net0=10.1.1.2; ing-net=10.1.1.3; net=10.1.1.4;"

$ echo "$input"  | sed -E 's,^[^|]+ \| ([^ ]+).* net=([0-9.]+).*$,\1: \2,g'
name-erkoev4ja3rv: 10.1.1.4
echo "6cb7f14e-6466-4211-9a09-2b8e7ad92703 | name-erkoev4ja3rv                              | 2e3900ff36574cf9937d88223403da77 | ACTIVE | Running     | net0=10.1.1.2; ing-net=10.1.1.3; net=10.1.1.4;"  | awk -F ' ' '{print $3}{print $13}' 

这是否满足您的要求?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM