Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Does grep-v support multiple keywords?

Shulou Source: shulou.com Published: 2022-06-03 05:58:47 10月12日 Update

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

Tags: Information commands keywords keywords network cards addresses multiple one go omnipotent at the same time requirements combinations support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Xiaomi Shulou Tech Info Huawei