Need help with egrep command

Id10t

New Member
Joined
Nov 4, 2018
Messages
7
Reaction score
2
Credits
0
Can anyone help me write an egrep command that will output all lines that contain 2 or more semi-colons. It seems simple but I've been stuck on this one for awhile now. Thanks
 


wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,957
Reaction score
7,925
Credits
37,761
G'day @Id10t and welcome to linux.org :)

I have moved this Thread to Command Line where it may attract more knowledgeable help.

It's beyond my paygrade but I will watch and learn ;)

Enjoy your Linux

Chris Turner
wizardfromoz
 
OP
Id10t

Id10t

New Member
Joined
Nov 4, 2018
Messages
7
Reaction score
2
Credits
0
G'day @Id10t and welcome to linux.org :)

I have moved this Thread to Command Line where it may attract more knowledgeable help.

It's beyond my paygrade but I will watch and learn ;)

Enjoy your Linux

Chris Turner
wizardfromoz
Thank you
 
OP
Id10t

Id10t

New Member
Joined
Nov 4, 2018
Messages
7
Reaction score
2
Credits
0
Can anyone help me write an egrep command that will output all lines that contain 2 or more semi-colons together or separate. It seems simple but I've been stuck on this one for a while now. Thanks

Update: I figured it out egrep '([^;]*;){2}' file

F.Y.I. Smiley wink is semicolon right parenthesis, I couldn't figure out how to keep the post from automatically posting the emoji equivalent.
 
Last edited:

CptCharis

Well-Known Member
Joined
Feb 27, 2018
Messages
563
Reaction score
465
Credits
982
Code:
grep -E '(;+)'

Easier? Moreover I think your command matches all ERE that don't start with a ; and contain 2 ;
 
Last edited:
  • Like
Reactions: Rob

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,957
Reaction score
7,925
Credits
37,761
In your Reply Pane toolbar/menu near right is a plus sign (+) in a square, click that, it has Quote, Spoiler, Code and Strike-through.

Code presents similar to the example posted by friend Capta above, so if I read your Post correctly, something like

Code:
egrep '([^;]*;){2}' file

... in fact copying and pasting your string reverts the emoji back. :)

Cheers

Wizard
 
OP
Id10t

Id10t

New Member
Joined
Nov 4, 2018
Messages
7
Reaction score
2
Credits
0
Code:
grep -E '(;+)'

Easier? Moreover I think your command matches all ERE that don't start with a ; and contain 2 ;
Thanks for the reply CptCharis but when i used your command it also highlighted lines with only 1 ;
 

Members online


Top