The grep command in Linux system is mainly used to search for strings and files. In fact, the grep command can search multiple words at the same time. Here's a look at how to use the grep command to search for multiple words under Linux.
Here's how:
grep ‘word1\\|
Word2\\|
Word3’ /path/to/file
In the following example, to find the words warning, error, and critical in a text log file called /var/log/messages, type:
$ grep ‘warning\\|
Error\\|
Critical’ /var/log/messages
Just match the word (that is, the word is delimited on both sides of the word, for Western-spaced languages), you can add the -w option parameter:
$ grep -w ‘warning\\|
Error\\|
Critical’ /var/log/messages
The egrep command can skip the above syntax format, using the following syntax:
$ egrep -w ‘warning|
Error|
Critical’ /var/log/messages
Add the -i (ignoring case) and --color option parameters as follows:
$ egrep -wi --color ‘ Warning|
Error|
Critical’ /var/log/messages
Output example:
The above picture shows the actual effect of using the grep command to search for multiple words under Linux. Now you know the grep command for Linux system. There is such an effect.
Scrot is a screenshot tool used in the Linux command line, can perform full screen, select and other
Ubuntu 12.04 is able to set the background color, but Ubuntu 12.04 can not modify t
Linux users when viewing the system log found that the iis server could not load the application /lm
Through the history command under Linux, we can view the used commands, that is, th
Two ways to protect VPS SSH account security under Linux
Ubuntu 12.04 system boot space is insufficient to delete the old kernel
How to use cgroups to manage CPU resources under Linux
Linux how to carry out Alibaba Cloud server FTP configuration
How to copy files between two Linux computers
How to use the Linux system Docker command
Linux using the fdisk tool to create partitions
Linux Logo Command Line Tool Installation and Use
Linux how to use the Xsnow command to display the snow effect on the desktop
Ubuntu notebook to increase heat dissipation through Bumblebee
Microsoft detailed Windows 8 system security performance improvement
Pirate free upgrade Win10 hourly black screen 1 time the truth!
Manually set the win7 virtual memory detailed process
How Win7 uses Disk Genius to detect and repair bad sectors of hard disk
FIFA14 officially landed in the Win8 app store
Win10 Wireless Network Management Change Tips
Prefetch engine opens twice as fast as the webpage! Sogou browser 5.0 officially released