Choosing words based on length
I have a large file containing text, one word per line. I want to keep only those lines in which the word length is a specific number of lower-case characters.
Suppose the desired length is 6. I tried this: egrep [a-z]{6} but it didn't do the job. Please advise. |
cat filename |cut -c 1-6 >> filename2
You can change the redirection to fit your needs. Although that only cuts the first 6 characters of each line. You'll need to look at sed to pick out just the lines containing exactly 6 characters. |
Try egrep '^[a-z]{6}$'
|
Perfect! Thank you! Solved!
|
All times are GMT -5. The time now is 06:58 AM. |