linux is the most commonly used commands, learn more about linux friends know; today a small ape circle linux teacher said about the use of the grep command, I hope you can see the master grep command, then look at the use of the grep command.
cat log.txt | grep conditions;
cat log.txt | grep condition a | grep second condition;
cat log.txt | grep condition a | grep second condition | grep Three conditions;
grep conditions for a log.txt | grep condition II | grep Three conditions;
No bullshit, such as the need to exclude mmm nnn abc.txt in
grep -v 'mmm\|nnn' abc.txt
But this is still a lot of need to go inside to find several pieces of information from this ip address need, we may think of using grep -v masked inet6, results are as follows:
bash-3.2 # ifconfig | grep inet | grep -v inet6
inet 127.0.0.1 netmask 0xff000000
inet 10.60.104.38 netmask 0xfffffe00 broadcast 10.60.105.255
The following commonly used filters linux grep command to look
The filtered content may be a phrase like, wrapped in quotation marks are required
1. Get keyword key file: cat fileName | grep "key"
2, a keyword key1 to obtain the file, key2, key3: cat fileName | grep -E "key1 | key2 | key3"
3, get more keywords in the file, while meeting: cat fileName | grep key1 | grep key2 | grep key3
4, ignoring file a keyword, you need to escape "|": cat fileName | grep -v "key1 \ | key2 \ | key3"
These are the small apes circle linux teacher to share the use of Linux grep grep commonly used screening of multiple conditions and filter commands, we want to help small partners.