In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces Linux using grep to filter multiple conditions and grep common filtering commands, friends who need can refer to.
Cat log.txt | grep condition
Cat log.txt | grep condition 1 | grep condition 2
Cat log.txt | grep condition 1 | grep condition 2 | grep condition 3
Grep condition 1 log.txt | grep condition 2 | grep condition 3
Don't talk nonsense, for example, you need to exclude mmm nnn from abc.txt
Grep-v 'mmm\ | nnn' abc.txt
However, this is still a lot. We need to find the required ip address from these messages. We may have thought of using grep-v to block inet6. The result is as follows:
1. | bash-3.2# ifconfig | grep inet | grep-v inet62, | inet 127.0.0.1 netmask 0xff0000003, | inet 10.60.104.38 netmask 0xfffffe00 broadcast 10.60.105.255
Let's take a look at the common filtering commands in linux grep
The filtered content can be a phrase, etc., and needs to be wrapped in quotation marks
1. Get the keyword key: cat fileName | grep "key" in the file
two。 Get one of the keywords key1, key2, key3: cat fileName in the file | grep-E "key1 | key2 | key3"
3. Get multiple keywords in the file and satisfy: cat fileName | grep key1 | grep key2 | grep key3
4. Ignore a keyword in the file and escape "|": cat fileName | grep-v "key1\ | key2\ | key3"
These are the details of how Linux uses grep to filter multiple conditions, please pay attention to other related articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.