cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2811
Views
15
Helpful
2
Replies

ACI grep for either/or

vv0bbLeS
Level 1
Level 1

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

RedNectar
VIP
VIP

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.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

View solution in original post

2 Replies 2

RedNectar
VIP
VIP

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.
Forum Tips: 1. Paste images inline - don't attach. 2. Always mark helpful and correct answers, it helps others find what they need.

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
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Save 25% on Day-2 Operations Add-On License