Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ grep command Series: grep command to search for multiple words     - How to Upgrade Ubuntu GNOME 14.10 to GNOME 3.16 Desktop (Linux)

- How to install the NVIDIA 358.16 driver in Ubuntu 15.10,14.04 (Linux)

- Oracle 11g RAC root.sh execution error second node failure example (Database)

- Install the Solaris 10 operating system environment over the network to sparc (Linux)

- Yii PHP Framework Getting Started tutorial (Linux)

- Hardware Firewall Basics (Linux)

- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)

- How to query the role of Linux services (Linux)

- How to install or upgrade to the Linux kernel in Ubuntu 4.2 (Linux)

- When the master key encounter NULL (Database)

- Linux Getting Started Tutorial: How to set up a static MAC address on VMware ESXi virtual machine (Mobile)

- Python calls the API interface in several ways (Programming)

- CentOS installation pycurl (Linux)

- Java MVC CRUD examples (Programming)

- Python2.7.7 source code analysis (Programming)

- RedHat Linux 6.4 installation RTL8188CUS wireless network card driver (Linux)

- After installing Ubuntu 15.04, to do a few things (Linux)

- To record command input under Linux (Linux)

- Fedora 22 users to install the VLC media player (Linux)

- Ubuntu file security removal tool (Linux)

  grep command Series: grep command to search for multiple words
  Add Date : 2018-11-21      
  To use the grep command to search for multiple strings or words, how do we do? For example, I want to find / path / to / file file word1, word2, word3 and other words, how do I look like grep command these words are there?

grep command supports regular expression pattern matching. To use multi-word search, please use the following syntax:

grep 'word1 \ | word2 \ | word3 ' / path / to / file
Under the example, to find a name in / var / log / messages log file in a text warning, error and critical these few words, enter:

$ Grep 'warning \ | error \ | critical ' / var / log / messages
Just to match the word (that is, both sides of the word is a word delimiter, separated by spaces for the West in terms of language), you can add -w option parameter:

$ Grep -w 'warning \ | error \ | critical ' / var / log / messages
egrep command can skip the above syntax, the use of syntax is as follows:

$ Egrep -w 'warning | error | critical ' / var / log / messages
I built the righteous of you add -i (ignore case) and --color option parameters, as shown here:

$ Egrep -wi --color 'warning | error | critical' / var / log / messages

Fig.01: Linux / Unix egrep Command Search Multiple Words Demo Output
- Elaborate 10-point difference between the new and malloc (Programming)
- How to use GRUB2 files directly from the hard disk to run ISO (Linux)
- Linux 10 useful examples of command-line completion (Linux)
- Three methods easy data encryption on Linux (Linux)
- Python is not C (Programming)
- Linux Mint brightness adjustment --xrandr command learning (Linux)
- Use cmake to compile and install MySQL 5.5 (Database)
- Linux Firewall Basics (Linux)
- Windows Remote Desktop Management CentOS 6.4 (Linux)
- How to create a remote (Linux)
- How to disable IPv6 in the CentOS 7 (Linux)
- Modify Linux SSH default port 22 in several ways (Linux)
- The file name is garbled or deleted files with special characters under Linux (Linux)
- How to Use Nmap security scanner tool on Linux (Linux)
- Ubuntu 14.04 How to set up an SSH without password (Linux)
- Open SSH remote access service that allows Android phone Ubuntu 14.04 (Linux)
- After VMware CentOS full VM clone the network card is unavailable Solutions (Linux)
- Objective-C basic program structure (Programming)
- Ubuntu 14.04 Boot Repair (Linux)
- zBackup: A versatile tool to remove duplicate backup (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.