{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COMP 328 Homework 4 Regular Expressions[1]

# COMP 328 Homework 4 Regular Expressions[1] - Find all lines...

This preview shows page 1. Sign up to view the full content.

COMP 328 Homework 4 Regular Expressions COMP 328 Homework 4 Regular Expressions (Using egrep For Searching a File) "egrep -n pattern filename " will not only look for the pattern in the file, but will tell you the line number where it found the match. Copy /home/lrakocy/dropbox/xfiles into your home directory and use it to answer the following questions: task egrep command Which line numbers? 1. Find all lines that contain Q or V. 2. Find all lines that begin with r, t, or c. 3. Find all lines that have the pattern "bb" someplace. 4. Find all lines that have a number (digit from 0-9). 5. Find all lines where the next to last character is a digit (0 – 9). 6. Find all lines that end with "ing." - note the period at the end. 7. Find all lines that contain "Don". 8.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Find all lines that contain a real number containing one or more digits before and after the decimal point. 9. Write a regular expression which matches lines which contain only digits, and whose length is >= 1. Create a small file to test your expression using egrep . egrep -n ^[0-9]+[^A-Za-z] hw4problem9Test 10. Modify your regular expression from problem 9 to match lines which contain only digits which represent a floating point number, such as +123.456, or -23.445. The leading + or – signs may or may not be present, but there must be at least one digit before the decimal point and at least one digit after the decimal point. Create a small file to text your expression on using egrep . Rakocy 5/8/2011 1:02 a5/p5 Page 1 of 1...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern