如何用shell取出如下字符中的ip地址?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何用shell取出如下字符中的ip地址?相关的知识,希望对你有一定的参考价值。
Failed password for adm from 58.248.38.108 port 21918 ssh2
Failed password for dds from 58.248.32.108 port 21918 ssh2
Failed password for invalid user student from 58.248.38.108 port 21918 ssh2
Failed password for invalid user stnt from 58.248.38.18 port 21918 ssh2
把上面内容保存到aa.txt文件中,然后执行上面语句。 参考技术B [seesea@UC ~]$ cat b.txt
Failed password for adm from 58.248.38.108 port 21918 ssh2
Failed password for dds from 58.248.32.108 port 21918 ssh2
Failed password for invalid user student from 58.248.38.108 port 21918 ssh2
Failed password for invalid user stnt from 58.248.38.18 port 21918 ssh2
[seesea@UC ~]$ grep -oP '\d+\.\d\+\.\d+\.\d+' b.txt
[seesea@UC ~]$ grep -oP '\d+\.\d+\.\d+\.\d+' b.txt
58.248.38.108
58.248.32.108
58.248.38.108
58.248.38.18本回答被提问者采纳
如何用JAVA获取本机的局域网IP地址?
如何用JAVA获取本机的局域网IP地址?
参考技术A InetAddress localAddress = InetAddress.getLocalHost();//获取ip地址然后编译系统会提示你抛出异常等,点击加入就行了
以上是关于如何用shell取出如下字符中的ip地址?的主要内容,如果未能解决你的问题,请参考以下文章