Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part B: Extract phone number from a file. Use vi to write the following content to file phone_numbers.txt. John: 123-456-7890 Jane: (555) 555-5555 Bob: 555-555-5555

Part B: Extract phone number from a file.

Use vi to write the following content to file phone_numbers.txt.

John: 123-456-7890

Jane: (555) 555-5555

Bob: 555-555-5555

The following grep command will extract all the phone numbers from the text file:.

grep -Eo '[0-9]{3}-[0-9]{3}-[0-9]{4}|\([0-9]{3}\)\ [0-9]{3}-[0-9]{4}' phone_numbers.txt

- Question : Attach screenshot of above.

Part C: Create your regex.

(1) Given a text file that contains a list of URLs, write a grep command that can extract only valid URLs from the file. A valid URL should start with http:// or https://, followed by one or more word characters (letters and numbers), and end with a .com, .org, .net, or .edu extension..

Question : what command you should use

Given a text file that contains a list of email addresses, write a grep command that can extract only valid email addresses from the file. A valid email address should contain a word character, followed by an @ symbol, then another word character, followed by a ., and ending with a two to six letter word character.

Question : what command you should use

Hint: you can use grep -E "Your regex" text_file.txt

You can create a file with the following content to test your command:

http://google.com

https://yahoo.org

https://abc.com

ABC(at)hmail.com

abc.def(at)otmail.com

invalid_email

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_2

Step: 3

blur-text-image_3

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions