Computing.Net > Forums > Unix > Grep problems

Grep problems

Reply to Message Icon

Original Message
Name: Kakashka
Date: November 19, 2003 at 22:09:21 Pacific
Subject: Grep problems
OS: XP
CPU/Ram: 366/500
Comment:

Hey guys. I have a problem with grep and do not know how to solve it. Can anyone help?

1. Write a command that uses grep with regular expressions to look for lines containing only (meaning it's the only string on that line) the string 'win' followed by one and only one vowel in a file called 'text.dat'.

2. Write a command that uses grep with regular expressions to look for the string 'win' followed by zero or more numbers, followed by one or more letters at the end of a line in a file called 'text.dat'.

3. Write a command that uses grep with regular expressions to look for the string 'wind' immediately followed by either the string 'mill' or 'ow' or 'chill' at the beginning of a line in a file called 'text.dat'

Thank you! :)



Report Offensive Message For Removal


Response Number 1
Name: hernandez
Date: November 20, 2003 at 02:51:17 Pacific
Reply: (edit)

This is the first one:

grep '^win[aeiou]$' text.dat

back in a bit...


Report Offensive Follow Up For Removal

Response Number 2
Name: hernandez
Date: November 20, 2003 at 03:38:37 Pacific
Reply: (edit)

This is the easiest way of doing the last one...

egrep '(^window|^windmill|^windchill)' text.dat


Report Offensive Follow Up For Removal

Response Number 3
Name: hernandez
Date: November 20, 2003 at 04:18:52 Pacific
Reply: (edit)

for the 2nd one...
if you have win followed by zero numnbers and then letters:
grep 'win[a-z]$' text.dat

and i'm trying to get the other bit to work with numbers


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Grep problems

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge