? Several ways to intercept IP using text tools in Linux

Source: Internet
Author: User

Several methods of using text tools to intercept IP in Linux

1, using the awk tool

[[Email protected] data]# ifconfig ens33ens33: flags=4163<up,broadcast,running, multicast>  mtu 1500        inet 192.168.1.140   netmask 255.255.255.0  broadcast 192.168.1.255         inet6 fe80::8abb:80e7:a0ad:6463  prefixlen 64  scopeid  0x20<link>        ether 00:0c:29:52:25:a4   txqueuelen 1000   (Ethernet)         rx packets  53417  bytes 5526762  (5.2&NBSP;MIB)          rx errors 0  dropped 0  overruns 0  frame 0         TX packets 4618  bytes 627215  (612.5  KiB)     &nbsP;   tx errors 0  dropped 0 overruns 0  carrier  0  collisions 0[[email protected] data]# ifconfig |awk -F  "   "   ' nr==2 {print $2} ' 192.168.1.140



2, using the SED tool

[[Email protected] data]# ifconfig ens33ens33: flags=4163<up,broadcast,running, multicast>  mtu 1500        inet 192.168.1.140   netmask 255.255.255.0  broadcast 192.168.1.255         inet6 fe80::8abb:80e7:a0ad:6463  prefixlen 64  scopeid  0x20<link>        ether 00:0c:29:52:25:a4   txqueuelen 1000   (Ethernet)         rx packets  53417  bytes 5526762  (5.2&NBSP;MIB)          rx errors 0  dropped 0  overruns 0  frame 0         TX packets 4618  bytes 627215  (612.5  KiB)     &nbsP;   tx errors 0  dropped 0 overruns 0  carrier  0  collisions 0[[email protected] data]# ifconfig |sed -n  " 2p "|sed  ' s#^.*net # #g ' |sed  ' s# net.*$# #g ' 192.168.1.140 [[email protected]  data]#  welcome everyone to join the discussion together to study progress together    I have been online

? Several ways to intercept IP using text tools in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.