cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
282
Views
10
Helpful
2
Replies
Highlighted
Beginner

ACI grep for either/or

Hello all,

I am trying to use grep to return multiple lines that may match different things (i.e. either/or). For example, say I have the following output on an APIC:

 

Node201

Node202

Node203

 

I would like to have grep return lines with EITHER "201" OR "202" in the line, so for the above output, I would like to have grep return:

 

Node201

Node202

 

I have tried using the | symbol and also regex grouping like so, but with no luck:

grep "201|202"

grep "(201|202)"

 

I have also tried grep -e as well as extended grep, also with no luck.

 

Does anyone know how I would return lines from output that matches multiple criteria in an either/or fashion?

0xD2A6762E
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Collaborator

Hi @vv0bbLeS ,

try using egrep (or grep -e) 

So you type

command egrep "20[12]"

I hope this helps

 



Don't forget to mark answers as correct if it solves your problem. This helps others find the correct answer if they search for the same problem


RedNectar
aka Chris Welsh


Don't forget to mark answers as correct if it solves your problem. This helps others find the correct answer if they search for the same problem

View solution in original post

2 REPLIES 2
Highlighted
Collaborator

Hi @vv0bbLeS ,

try using egrep (or grep -e) 

So you type

command egrep "20[12]"

I hope this helps

 



Don't forget to mark answers as correct if it solves your problem. This helps others find the correct answer if they search for the same problem


RedNectar
aka Chris Welsh


Don't forget to mark answers as correct if it solves your problem. This helps others find the correct answer if they search for the same problem

View solution in original post

Highlighted

Wow DUH I didn't even think about using character classes lol, that works perfectly! And i also tried it with regular grep and it also works with that. Thanks again!

0xD2A6762E