Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

shell scripting, write a series of grep statements that do the following: 1. Pri

ID: 3890316 • Letter: S

Question

shell scripting, write a series of grep statements that do the following:

1. Print all lines that contain a phone number with an extension (the letter x or X followed by four digits).

2. Print all lines that begin with three digits followed by a blank. Your answer must use the { and } repetition specifier.

3. Print all lines that contain a date. Hint: this is a very simple pattern. It does not have to work for any year before 2000.

4. Print all lines containing a vowel (a, e, i, o, or u) followed by a single character followed by the same vowel again. Thus, it will find “eve” or “adam” but not “vera”. Hint: ( and )

5. Print all lines that do not begin with a capital S.

6. Print all lines that contain CA in either uppercase or lowercase.

7. Print all lines that contain an email address (they have an @ in them), preceded by the line number.

8. Print all lines that do not contain the word Sep. (including the period).

9. Print all lines that contain the word de as a whole word.

Your patterns should work in any generic file of this sort. They should not be dependent upon the data in this particular file; if I add more lines of the same form to the file, your patterns should still work.

Explanation / Answer

1. grep "[xX]d{4}" filename
2. grep "^d{3} " filename
3. grep "$(date +"%Y-%m-%d")" filename

4. Still working on it.
5. grep -v "^S" filename
6. grep -i "CA" filename
7. grep -n "@" filename
8. grep -v "Sep." filename
9. grep -w "de" filename