Question

How do I write a bash script that uses the 'egrep' command to list files containing...

How do I write a bash script that uses the 'egrep' command to list files containing either 'a' followed by 'g' or 'g' followed by 'a' (possibly with characters in between)?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

egrep - Extended Global Regular Expressions Print

egrep is used for matching a specified pattern. egrep is grep command as 'gerp -e' .

Multiple pattern matching is done with OR condition (|).

* - items will be matched zero or more than one times.

syntax:

egrep ' pattern1|pattern2' file name

Code:

$ egrep ' * (ag|ga)*' *.txt

or

$ egrep '(ag|ga)*' *.txt

Matches with more than one text files.

For specific file:

$ egrep ' * (ag|ga)*' file.txt

or

$ egrep '(ag|ga)*' file.txt

Add a comment
Know the answer?
Add Answer to:
How do I write a bash script that uses the 'egrep' command to list files containing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT