Reputation: 564
Hi so I'm new to using egrep and I'm having a bit of trouble trying to get this to work
So I have a textfile with one word in it and I need to check the length of the word
I'm testing if the word is between 6 to 32 characters long and here's the command that I'm using
egrep '.{6,32}' file.txt
It does detect that the word is less than 6 characters but it doesn't work for words longer than 32 characters long
Am I doing something wrong?
Thanks!
Upvotes: 2
Views: 607
Reputation: 368954
Use ^
(matches at the beginning of the string) and $
(matches at end of the string) to match the whole word:
egrep '^.{6,32}$' file.txt
Upvotes: 2