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

martiniii

New Member
Joined
Jan 20, 2021
Messages
2
Reaction score
1
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
 


Hmm....

This gets you a little closer - but we're gonna need Jas for this one.

cat /etc/group | grep -E '(^|[^0-9])[0-9]{2}($|[^0-9])'
 
I managed to get it working with
cat /etc/group | egrep -v "^[0-9]" | egrep "[0-9]{2}" | egrep -v "[0-9]{3}"
 
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}"
 
I can never remember your entire username, 'cause I so woulda pinged you to the thread. ;-)
 
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?
 
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 :)
 

Staff online

Members online


Latest posts

Top