I have literally spend 10 hours trying to figure out this question. I have tried the all sorts of combinations of grep to answer the following question for an assignment.
contents of file f3.txt (excluding the ------- )
--------------------------------------------------------------------------------------------------------
The American Revolution.
This is the best solution to the problem
PanAmerica Capital Group
the american people
ddd
United States of America
america
the brown fox jumped over a lazy dog.
Creative thinking
----------------------------------------------------------------------------------------------------------
Two questions are:
1)List all the lines in the “f3.txt” file that contain words which contain exactly one vowel.
2)List all the lines in the “f3.txt” file that contain words which begin and end with a consonant but otherwise consist only of vowels.
So far I have this:
• grep -w '^[^aeiou]*[aeiou][^aeiou]*$' f3.txt
And honestly I am not sure what this does or if its even possible to get a result using the supplied file.
Please help
Please help with grep linguistics
Moderator: General Moderators
-
mykg4orce1
- Forum Newbie
- Posts: 1
- Joined: Sun Nov 05, 2006 4:47 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Sounds a bit like a homework assignment. 
Code: Select all
[feyd@home]>grep -w "[^aeiou]*[aeiou][^aeiou]*" grep.txt
The American Revolution.
This is the best solution to the problem
the american people
United States of America
the brown fox jumped over a lazy dog.
[feyd@home]>grep -P "\b[^aeiou][aeiou]+[^aeiou]\b" grep.txt
This is the best solution to the problem
United States of America
the brown fox jumped over a lazy dog.
[feyd@home]>grep -V
grep (GNU grep) 2.5.1
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.