egrep "[0-9]{2}" not working

martiniii

New Member
Credits
20
Hello, Im sorry to bother you with this, but I´m new to this and need help to get it working properly.
I need to get only the lines that don´t start with number and have two digit number in them.
I have this command:
cat /etc/group | egrep -v "^[0-9]" | egrep "[0-9]{2}"
And the problem is that it´s not showing only lines with two digit number. Good sign is that it´s showing lines with more than two digit. I tried also {2,2} and it´s doing the same think (showing lines with 2+ digit number)

thanks for your help
 


JasKinasis

Well-Known Member
Credits
5,358
Looks like I'm a little late to the party.
One thing:
When using grep, you don't need to use cat. You can just use grep on its own:
Bash:
egrep -v "^[0-9]" /etc/group | egrep "[0-9]{2}" | egrep -v "[0-9]{3}"
 

simba07565

New Member
Credits
10
Hello, Im sorry to bother you with this, but I´m new to this and need help to get it working properly.
I need to get only the lines that don´t start with number and have two digit number in them.
I have this command:
cat /etc/group | egrep -v "^[0-9]" | egrep "[0-9]{2}"
And the problem is that it´s not showing only lines with two digit number. Good sign is that it´s showing lines with more than two digit. I tried also {2,2} and it´s doing the same think (showing lines with 2+ digit number)

thanks for your help
Have you solved it?
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
11,451
Morning all, moving this to our Command Line subforum, where Jas has a lounge chair, slippers and pipe set up :)

https://linux.org/forums/command-line.145/

@martiniii , @KGIII , @JasKinasis and @simba07565 take note.

Hang on to your hats and we'll take a magic carpet ride there.

Wizard

BTW - Jas was a drummer with UK prog rock band Kinasis, now he is with No Thursday War but @JasNoThursdayWar doesn't have the same ring to it. Just start to type in @jas and the rest will autocomplete :)
 
Top