How To Exclude with Grep In Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/exclude-grep-linux/
PINTEREST
PINTEREST
INSTAGRAM

grep is very useful tool used by a lot of tech guys. grep provides different functions to match given text. We have all ready mentioned these useful options of grep. In this tutorial we will look different ways to exclude in grep.

Linux egrep Command Tutorial with Examples

Exclude with -v  Option

The basic way to exclude given term line from given text is -v  option. This will look for given term and remove line which contains term. In this example we will remove lines contains IP address 192.168.1.1 by using -v option.

How To Exclude with Grep In Linux?
How To Exclude with Grep In Linux?

Multiple Exclude with Multiple Grep

What if we need multiple excludes? We can use multiple grep too. We can pipe multiple grep end to end. We will exclude poftut  and com terms from file named syslog.1 with the following command.

Multiple Exclude with Extended Regex

grep  command provides extended regex functionality. This is used to provide multiple regex pattern in a single shot. We can use this feature in order to exclude multiple terms. We will use -e  option and provide regex patterns. We will exclude dhclient  and com with the following command.

Multiple Exclude with Extended Regex
Multiple Exclude with Extended Regex

Exclude Tail Command Output

tail command provides the ability to read log files by streaming. But if there is a lot of logs this may be hard to read. We can use grep  with tail  command to gather to filter unwanted lines. We will pipe the tail  command output to the grep  command. We will filter lines those provides anacron

Exclude with Tail Command
Exclude with Command Output

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/exclude-grep-linux/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  Linux Cut Command With Examples