Linux command line question: For each of the following text search criteria, provide a regular expression that matches the criterion, suitable for…

Linux command line question: For each of the following text search criteria, provide a regular expression that matches the criterion, suitable for….

Linux command line question:

For each of the following text search criteria, provide a regular expression that matches the

criterion, suitable for use with egrep. Your answer in each case should be a text le that

contains just the regular expression, on a single line (again, use wc to verify this). If your

pattern contains special characters, enclose it in quotes.

(a) Lines that contain both “cs246” and “cs247”.

(b) Lines that contain nothing but a single occurrence of laughter, where laughter is dened

as a string of the form Hahahahahahahahahahahahahaha!, with arbitrarily many ha’s.

(c) Lines that contain nothing but a single occurrence of generalized laughter, which is

like ordinary laughter, except that there can be arbitrarily many (but at least one) a’s

between each pair of consecutive h’s. (For example: Haahahaaaa!) Place your answer

in the le a1q2c.txt.

(d) Lines that contain at least one a and at least two b’s.

Place your answer in the le a1q2d.txt.

(e) Lines consisting of a denition of a single C variable of type int, without initialization,

optionally preceded by unsigned, and optionally followed by any single line // comment.

Example:

int varname; // comment

You may assume that all of the whitespace in the line consists of space characters (no

tabs). You may also assume that varname will not be a C keyword (i.e., you do not

have to try to check for this with your regular expression). Place your answer in the le

a1q2e.txt.

Linux command line question: For each of the following text search criteria, provide a regular expression that matches the criterion, suitable for…