Question: Objective: To learn the functionality of grep command and use regular expressions In your home directory create files f1.txt, f2.txt, and f3.txt with the following

Objective: To learn the functionality of grep command and use regular expressions

In your home directory create files f1.txt, f2.txt, and f3.txt with the following content:

f1.txt

America is a great country.

LITTLE MARY

f2.txt

Little Mary

f3.txt

The American Revolution.

This is the best solution to the problem

PanAmerica Capital Group

the american people

ddd

United States of America

america

the brown fox jumped over a lazy dog.

Creative thinking

Write grep commands to accomplish the tasks listed below:

  1. List all the files in your home directory that contain the little Mary word phrase. Make the search case insensitive.

Answer:

  1. List all the lines in the f3.txt file that contain words America or america (only letter a could be in either lower or upper case. The rest of the world is in all lower case letters. Please note that you are asked to search for words. Therefore, lines containing American or PanAmerica etc should not be listed.

Answer:

  1. List all the lines in the ftxt file that begin with the words The or the. Only letter t could be in either lower or upper case. The rest of the word is in all lower case letters.

Answer:

  1. List all the lines in the f3.txt file that end with a . character.

Answer:

  1. List all the lines in the f3.txt file that begin with either The or the and end with a . character. Please note the case sensitivity requirement described in question 3.

Answer:

  1. List all the lines in the f3.txt file that contain words which contain exactly one vowel. Make the search case insensitive.

Answer:

  1. List all the lines in the f3.txt file that contain words with a character b not followed by a character e. Make the search case insensitive.

Answer:

  1. List all the lines in the f3.txt file that contain words which begin and end with a consonant but otherwise consist only of vowels. Make the search case insensitive.

Answer:

  1. List all the lines in the f3.txt file that contain the words which contain no vowels. Make the search case-insensitive.

Answer:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!