Skip to main content

How to search for a pattern of words in shell script? [Resolved]

I want to search for a pattern of words in a text file. The pattern is like:

Summary: ........... Fault

The dots indicate anything can come in between. How can this be done in shell script?

Question Credit: Devjith
Question Reference
Asked September 13, 2018
Tags: shell, grep
Posted Under: Unix Linux
1 Answers

Use the 'General Regular Expression Parser' utility, aka grep. Suppose the name of your file is dump.txt. Use the command:

cat dump.txt | grep "Summary: .*Fault"

Hope it helps.

credit: 7_R3X
Answered September 13, 2018
Your Answer