CLI output filter

Reply
Highlighted
L0 Member

CLI output filter

Hello,

I would like to know if there's way how to "chain" multiple variables after pipe in some command to filter the output, something like:

<command> | match <param1>|<param2>

For example:

show running security-policy | match index|source|destination|application

 

I tried to play around with quotation marks, brackets and so on but did not get it working, only with one variable. And I consider something like that one of very basics for efficient CLI use.

Any idea how to get thsi working?

Thanks in advance!


Accepted Solutions
Highlighted
L7 Applicator

Re: CLI output filter

You can use this syntax:    show command | match param1\|param2 

 

The key is the \| between parameter1 and parameter2.  Here's "show system info" only showing the lines including "ipv6" or "wildfire" (bold added for emphasis):

 

admin@pa0-black_knight(active)> show system info | match ipv6\|wildfire

ipv6-address: unknown

ipv6-link-local-address: fe80::250:56ff:fe82:7c03/64

ipv6-default-gateway:

wildfire-version: 235397-237863

wildfire-release-date: 2018/04/14 22:09:36 MDT

 

admin@pa0-black_knight(active)>

View solution in original post


All Replies
Highlighted
L7 Applicator

Re: CLI output filter

You can use this syntax:    show command | match param1\|param2 

 

The key is the \| between parameter1 and parameter2.  Here's "show system info" only showing the lines including "ipv6" or "wildfire" (bold added for emphasis):

 

admin@pa0-black_knight(active)> show system info | match ipv6\|wildfire

ipv6-address: unknown

ipv6-link-local-address: fe80::250:56ff:fe82:7c03/64

ipv6-default-gateway:

wildfire-version: 235397-237863

wildfire-release-date: 2018/04/14 22:09:36 MDT

 

admin@pa0-black_knight(active)>

View solution in original post

Highlighted
L0 Member

Re: CLI output filter

Hi,

This is great info, thank you!

By the way, is there also a way to mix 'match' and 'except' parameters? For example like:

show system info | match ipv6\|wildfire | except version

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the Live Community as a whole!

The Live Community thanks you for your participation!