Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

Small tip | Search for multiple patterns / expressions using grep

Date: 2011-05-01 00:00:00 -0400

Introduction

If you want to search for multiple expressions while using grep you can do it, grep will use all expressions you pass to it, and will apply a logic or to them.

So, if any of them is present the line with that occurrence will be printed.

Specify multiple expressions / patterns to search for to grep

The option that will help use doing this is -e.

grep -e pattern1 -e pattern2 -e pattern3 /folder/file

Easy as you can see.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.