What command I need to use to search for two strings such as ‘containerSciFilter’ and ‘backgroundProcessorDelay’ in a Linux server? I need to use grep as file is huge.
You can grep two strings and words easily using the following syntax
grep -E 'string1|string2' filename
egrep 'word1|word2' /path/to/file
Grepping two strings / words
grep -E 'containerSciFilter|backgroundProcessorDelay' /path/to/config.file
Make it case insensitive search so that it will match both upper and lower case (or combination of both) words/strings by passing the -i:
egrep -i 'containerSciFilter|backgroundProcessorDelay' /path/to/config.file
Restrict search to marching words only:
egrep -i -w 'containerSciFilter|backgroundProcessorDelay' filenme
Where,
-i
: ignore case distinctions in patterns and data-w
: match only whole words-E
: PATTERNS are extended regular expressions
Take a look at my guide:
https://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/
1 Like