grep and regular expressions.
Points : 60
Due : Thursday, 2 Nov. 2017

You are to create a regular expression that prerforms the search described in each of the questions below. I've listed all available questions. You are expected to do 15 of these.

There is a link below that will take you to a web page that will pick the 15 questions you need to do for the asignment. This set is unique to your z-id.

Click here to get the list of the 15 questions. Print this out.

Put your solutions in a shell script so you can edit and tweak them until you get it right.

Insert the following at the top of the solutioni script.

There are two separate data files. Your solution should work on both and produce the right output. The output won't be same because the data files are different.

I've tried to use terms carefully.

You may use literal ranges, [a-z], or the symbolic form, [[:lower:]], where appropriate, unless specifically told to use a certain form.

Write your solutions in a script file using the following command sequence style.

# 01 - find all lines containing a word ending in s in words.

grep "s$" $lines1 | tee gout.01a | wc
grep "s$" $lines2 | tee gout.01b | wc

# 02 - ...
The tee will create a file of lines that match. Examine the file (less gout.01a) and see if you can identify the matches. The wc will generate a count characters, words, and lines as a quick check. I will post a wc count for each question.

List of word counts for each question.

YOu can also so a couple of comparison checks. In your current login shell, create a local variable :

You can then do a diff between your output and mine. You can also do a head on my output and your output.

Find a solution each question assigned to you. When done, email the grep script file to me on turing/hopper.

mutt -s grepassn berezin < grepassn

Hints


Here is the list of all 50 questions. You may try all of them if you want. But, the 15 chosen above are required to complete the assignment.

01. Find any line with a digit in it.

02. Find any line with two digits anywhere in it.

03. Find any line with two digits next to each other.

04. Find any line with the same letter immediately following the 1st.

05. Find any line with a pair of letters repeated anywhere else on the line.

06. Find any line with a pair of letters repeated anywhere else in the same word.

07. Find any line with a pair of letters repeated immediately after the 1st pair.

08. Find any line with a pair of letters repeated anywhere else on the line in reverse order.

09. Find any line with a pair of letters repeated anywhere else in the same word in reverse order.

10. Find any line with the same character occurring two more times anywhere on the line.

11. Find any line with a set of 3 letters repeated next to the 1st three.

12. Find any line with three consecutive letters repeated next to the 1st three in reverse.

13. Find any line with three consecutive letters repeated anywhere else on line, but not next to each other.

14. Find any line with three consecutive letters repeated anywhere else on line in reverse, but not next to each other.

15. Find any line with a capital letter in it.

16. Find any line with one and only capital letter in it.

17. Find any line with two words anywhere on the line starting with a capital letter.

18. Find any line with two words next to each other starting with a capital letter.

19. Find any line with two consecutive capital letters.

20. Find any line with the same letter repeated elsewhere in the same word but not next to itself.

21. Find any blank lines.

22. Find any line longer than 6 characters.

23. Find any line longer than 8 characters.

24. Find any line with exactly 5 characters.

25. Find any line with exactly 8 characters.

26. Find any line with exactly 2 characters.

27. Find any line with 1st word capitalized.
There may be initial white-space.

28. Find any line with with a word with the 2nd character capitalized.

29. Find any line with a word with only the 2nd character capitalized.

30. Find line that has exactly 3 words.

31. Find any line with a word longer than 6 characters.

32. Find any line with a word longer than 10 characters.

33. Find any line with a word exactly 6 characters.

34. Find any line with a word exactly 10 characters.

35. find any line with two 6-character words anywhere on the line.

36. Find any lines with no punctuation in it. But, do not match blank lines.

37. Find any line with punctuation in it.

38. Find any line with at least 3 punctuations in it.

39. Find any lines with no punctuation in it. Blank lines may match.

40. Find any line where only the last letter is capitalized.

41. Find any line that has at least 3 words.

42. Find any line with two words 6 characters long next to each other. There may be punctuation between the words.

43. Find any line with a word that begins and ends with the same character.

44. Find any line with a word with the 2nd character and second to last characters match. Letters may be next to each other.

45. Find any line with a word with the 2nd character and second to last characters match. Letters must be separated by at least one other letter.

46. Find any line with 2 periods on the line.

47. Find any lines with 2 6-character words next to each other separated by a punctuation and a space.

48. Find any line with a 5-character sequence repeated anywhere else on the line.

49. Find any line with just 5-letters long. Line may end with punctuation. (6th character)

50. Find any line with just 1 word and line ends with punctuation.

51. Find any line with just 2 words and at least one word is immediately followed by punctuation.
There may be additional spacing and punctuation on the line
Consider options to specify two alternative regular expressions.

52. Find any line with a word less than 6 characters.

53. Find any line with a word less than 10 characters.

54. Find any line with only words less than 6 characters.
Consider options for finding non-matches.
You may get blank lines.

55. Find any line with only words less than 10 characters.
Consider otions for finding non-matches.
You may get blank lines.

56. Find any line with only words greater than 6 characters.
Consider options.

57. Find any line with only words greater than 10 characters. Consider otions.