1. What are regular expressions? What are they used for? (each 10 points)

2. Assume you have a file that contains these lines:

a3b

adcbcbc

12c5a36

a5

3c

1) In the above file which line(s) will match the regular expression of ‘[a3][5c]’ ? (10 points)

2) In the above file which lines will the regular expression of ‘^.3.*b’ match? (10 points)

3. Explain what this regular expression will match: (10 points)

   abcd{5}

4. Write a grep command that get a list of files that contain the string zip preceded by any character except b or g. (10 points)

5. Given a file containing the lines at the right, list which lines will be matched by each of the following egrep patterns: (each 5 points)

cat
catch
cart
crepe
oxcart
encarta
fire
fireplace
family
fame

1. ‘^c’

2. ‘e$’

3. ‘^….$’

4. ‘c.r’

5. ‘t.$’

6. ‘t.?$’

7. ‘t.+$’

8. ‘t.*$’

9. ‘^.[ai]’

10. ‘^.[^ai]’

1. What does the following awk command do and output? (20 points)

     awk  



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *