[sf-lug] regex: how to match any one to four character word in a file

jim jim at well.com
Wed Dec 10 08:37:02 PST 2008

i've given up on the online tutorials. 

i have a text file with over 100000 words (and lines, 
one word per line). i wanna grep out all words that 
are from one to four characters, e.g. 'a' or 'and' 
or "fact" but not "apple" or "zounds". 

$  grep '[.]{4}' words.txt
got me a newline. 

i've got lots of other variations in my .bash_history 
if anyone wants a good laugh. 

More information about the sf-lug mailing list