Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

grep multiple

Use | to separate multiple patterns for the OR condition.

Example: grep 'pattern1|pattern2' filename

Use the -E option to send multiple patterns for the OR condition.

Example: grep -E 'pattern1|pattern2' filename

Using a single -e matches only one pattern, but using multiple -e option matches more than one pattern.

Example: grep -e pattern1 -e pattern2 filename

grep -v can simulate the NOT operation.

There is no AND operator in grep, but you can brute-force simulate AND by using the -E option.

Example : grep -E 'pattern1.*pattern2|pattern2.*pattern1' filename

The above example will match all the lines that contain both pattern1 and pattern2 in either order.)
Comment

grep in multiple files

grep -E 'fatal|error|critical|failure|warning|' *.log
Comment

PREVIOUS NEXT
Code Example
Shell :: change commit author after push 
Shell :: git reset last commit keep changes 
Shell :: access wine directory mac os 
Shell :: linux command for file size 
Shell :: docker compose no space left on device 
Shell :: bash open program 
Shell :: startup folder location 
Shell :: copy folder from on server machine 
Shell :: npm install from github branch 
Shell :: clean remove npm with cache 
Shell :: reset to origin 
Shell :: gradle threw an error while downloading artifacts from the network. retrying to download 
Shell :: mac check command line tools version 
Shell :: Iterate over only folder in bash 
Shell :: create cert from pem 
Shell :: bash add new line to crontab 
Shell :: git remove file from history 
Shell :: check if a port is working 
Shell :: xsltproc linux install 
Shell :: ubuntu git https not supported 
Shell :: bash new folder 
Shell :: list of git branches 
Shell :: ubuntu install jellyfin 
Shell :: how to switch php versions 
Shell :: start xampp 
Shell :: linux make user like root 
Shell :: conda install packages from requirements.txt 
Shell :: linux process holding deleted file 
Shell :: heroku rebuild 
Shell :: list all running processes linux 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =