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

Unix Programming d) Give regular expressions (such that could be used with grep

ID: 3817576 • Letter: U

Question

Unix Programming

d) Give regular expressions (such that could be used with grep and egrep) for each of the following:

- All lines ending with the phrase ‘here below’

- All lines that end in either ‘y’ or ‘z’

- All lines that contain the word ‘index’ followed by any odd number/digit followed by any even number/digit (ignore 0’s)

- All lines that contain either 0 or 1 instances of the character ‘R’, but no more

- All lines that contain a word with 1 or more of the letter ‘a’, followed by 0 or 1 of the letter ‘b’, followed by the letter ‘c’

Explanation / Answer

1- All lines ending with the phrase ‘here below’

grep 'here below$' filename

2- All lines that end in either ‘y’ or ‘z’

with grep: grep 'y$|z$' filename

with egrep: grep 'y$|z$' filename

3- All lines that contain the word ‘index’ followed by any odd number/digit followed by any even number/digit (ignore 0’s)

egrep 'index[13579]*[2468]*' filename

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote