Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Regular Expression Exercise 1 Write a statement with the grep command and regular expressions to find the given pattern for each one of the cases

Regular Expression Exercise 1

Write a statement with the grep command and regular expressions to find the given pattern for each one of the cases on the following list.

1. Try this on the command line and explain what it is doing: grep hom.*ds p*

2. Print all lines containing the expression 70 in " peopleonEarth.txt "

3. Print all lines beginning with a t or T

4. Print all lines ending with a 4

5. Print all lines containing people

6. Print all lines containing the number 4

7. Print all lines containing the number 4 followed by a comma ,

8. Print all lines containing the expression ,4

9. Print all lines containing the number 4 followed by a comma , and any single character

10. Print all lines beginning with either an I or a T

11. Print all lines containing one non-digit

12. Print all lines containing digits followed by a space and a capital letter

13. Print all lines containing an s followed by zero or more consecutive occurrences of the letter s and a space.

14. Print all lines containing at least nine consecutive lowercase letters (i.e. northeast)

15. Print all lines containing a word starting with human

16. Print all lines if they contain the word million

17. Print all lines containing a word starting with a lowercase letter and followed by any number of characters and ending with t

Exercise 2

In this exercise you are going to examine Grep with options.

1. Print all lines beginning with either an I or a T and try in this case to execute the grep command with each one of the following options (individually, not all of them at the same time): -n, -i, -l, -c, -w. Whats the result for each one?

2. Print all lines if they contain the word million and try in this case to execute the grep command with each one of the following options (individually, not all of them at the same time): -v, -l, -w.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions