Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer programming Chapter 11 Exercises Exercise 1: Write a simple program to simulate the operation of the grep command on Unix. Ask the user to

Computer programming

Chapter 11 Exercises

Exercise 1: Write a simple program to simulate the operation of the grep command

on Unix. Ask the user to enter a regular expression and count the number

of lines that matched the regular expression:

$ python grep.py

Enter a regular expression: ^Author

mbox.txt had 1798 lines that matched ^Author

$ python grep.py

Enter a regular expression: ^Xmbox.

txt had 14368 lines that matched ^X-

$ python grep.py

Enter a regular expression: java$

mbox.txt had 4218 lines that matched java$

Exercise 2: Write a program to look for lines of the form

`New Revision: 39772`

and extract the number from each of the lines using a regular expression and

the findall() method. Compute the average of the numbers and print out the

average.

Enter file:mbox.txt

38549.7949721

Enter file:mbox-short.txt

39756.9259259

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

1. What does the term employment relationship mean?

Answered: 1 week ago