Deliverables: One text file, regex.txt, that contains the full egrep commands as
ID: 3729492 • Letter: D
Question
Deliverables: One text file, regex.txt, that contains the full egrep commands as typed at the Linux command prompt (12 commands in total). The following questions refer to Edgar Allen Poe's poem "The Raven", which is available for download on Moodle. Use egrep to find the answers to the following case-sensitive questions 1- a) The lines containing, but don't start with, the word raven. b) The blank lines. c) The lines with at least 40 characters. d) The nonempty lines with no punctuation characters. e) The lines with an uppercase letter ignoring the first character on each line. 0 The lines that have at least two p's (consecutive or nonconsecutive) followed by ore, not necessarily immediately after g) The lines that have two consecutive words where the last letter in the first is the first letter in the second. h) The lines with 3 sets of double letters (the sets may or may not contain the same letters). i) The lines having 5 consecutive letters forming a palindrome. A word is defined as a series of letters with no space or punctuation characters in between Give the three regular expressions required to produce the results: 2. a) Lines that contain A or a at some index m, and Z or z at some index n, where n>m b) Lines consisting solely of US postal code, allowing both the five-digit and nine-digit (called ZIP+4) formats. Lines containing nothing but an integer between e and 211, inclusive. c)Explanation / Answer
use egrep to find answers to the following case-sensitive questsion
a) The lines containing, but dont start with, the word 'raven'
egrep -v '^raven' raven.txt | egrep 'raven'
b) blank lines
egrep '^s*$' raven.txt
c) lines with at least 40 characters
egrep '.{40,}' raven.txt
d) nonempty line with no punctuation characters
grep '^[^[:punct:]]+$' raven.txt
e) lines with an uppercase letter ignoring the first character on each line
egrep '^.+?[A-Z]+' raven.txt
f) lines that have atleast two p's followed by 'ore', not necessarily immediately after'
egrep '[p].*[p].*ore' raven.txt
g)The lines that have two consecutive words where the last letter in the first is the first
letter in second
egrep '(.)s+' raven.txt
h) lines with 3 sets of double letters (sets may / may not contain same letters)
egrep '(.)(.)(.).*?' raven.txt
i) lines havin 5 consecutive letters forming a palindrom
egrep '(.)(.)(.)' raven.txt
2) give regex
a) Lines that contan A or a at some index m , and Z or z at some index n, where n > m
'[A|a].*[z|Z]'
b) Lines consiting solely of US postal code, allowing both 5-digit and nine-digit called(zip+4) fommats
'^d{5}|d{9}$'
c) lines containing nothing but an integer between 0 and 211 , inclusive
'^([01]?[0-9]?[0-9]|2[0-1][0-1])$'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.