COMP 328 Homework 4 Regular Expressions[1]

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1
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

This note was uploaded on 05/08/2011 for the course ECET 220 taught by Professor Smith during the Spring '11 term at DeVry Austin.

Ask a homework question - tutors are online