Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does grep-v support multiple keywords?

2025-02-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Requirement: to get the network card and its corresponding IP address.

We all know that we can use grep-v to filter out information that matches keywords. Use the grep command to get the information of the network card and the corresponding IP.

Ip addr | awk {'print $1J 2'} | grep-v link | grep-v valid | grep-v inet6

Through this combination of commands, you can get the information you want, but this command is a bit long, has it been done in one fell swoop?

Grep-v 'keyword1\ | keyword2' can filter out multiple keyword information at the same time. Combined with the command of sed, you can delete redundant keywords and easily obtain Nic and IP address information.

Ip addr | awk {'print $1 link 2'} | grep-v' link\ | valid_lft\ | inet6' | sed s/'inet'//g | sed sdebar'^ [0-9]:'/''/ g

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report