grep commands

C

CrazyRunner2311

Guest
I have been working on this shamefully for over 6 hours.

Suppose you were working a word puzzle and needed a 5-letter word beginning with 'd' (upper or lower-case) followed immediately by a lower-case vowel (including 'y') and ending with 's'. The remaining letters could be any character that occurs in English words, including upper and lower-case alphabetics, hyphens, etc. (We will accept the file /usr/share/dict/words as the authority on what constitutes a valid English word.)

What grep command would you use to list the words from /usr/share/dict/words that match this requirement?

I am running this via ssh in terminal on my mac.

I have tried various assortments of grep & egrep command lines and am not getting anywhere.

What command would you enter to see 5-letter words that begin with 'd' (upper or lower-case), followed by a lower-case vowel, and ending in 's'?

egrep '[dD][aeiouy][a-zA-Z]{2}s' /usr/share/dict/words

No. That's not it.
An example of a word that you accepted, though you should not have, is: Adidas

when i try to add a parameter for word length before the letter specs the system crashes.
IE: ' [1-5]

I am at a loss. I have read online tutorials and purchased two linux/unix books from barnes an noble can someone please explain this to me and where I am making my error?
 


egrep '^[dD][aeiouy][a-zA-Z]{2}s$' /usr/share/dict/words
 
egrep "^[Dd][aeiouy]..s$"

Might work, although '.' may pick up characters you don't want not sure.

Also you forgot the ^ anchor in thrivequake's post, which is why Adidas matched.
 
Last edited:

Members online


Top