Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
FlashOver
New Contributor

grep the grep command on CLI ?

Can I grep and grep output the get more detailed information. For example, I like to see only the policy number where wan1 is used for example When I do: show firewall policy | grep -B 2 wan1 I get three lines per policy.... but I like to grep the grep output like that. show firewall policy | grep -B 2 wan1 | grep edit is that possible? And if not - where to request that as improvement?
7 REPLIES 7
ede_pfau
Esteemed Contributor III

No, chaining is not possible in the CLI. I suspect it' s not a true shell, just parsed input. A feature request for a full shell (ksh or bash...) would find quite a lot of support I guess, with more than a meagre ' grep' .

Ede

"Kernel panic: Aiee, killing interrupt handler!"
Ede"Kernel panic: Aiee, killing interrupt handler!"
emnoc
Esteemed Contributor III

is that possible? And if not - where to request that as improvement?
Contact your regional sales team and SE. if your a customer and have an account with fortinet they will push a request. I' ve asked for the same thing a full shell like what you have on a juniper SRX for example. I' m really surprise fortinet has not made that a function.

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
fropert_FTNT
Staff
Staff

Hello, Since 5.0.4 (if I remember correctly) grep -f will do grep per configuration section context and pinpoint the grepped word (wan1 in this forum post case) with arrows " <----" . Regards, Francois
emnoc
Esteemed Contributor III

for the OP I would try a different approach

 

diag sys checkused system.interface.name wan1

 

That will list the  policy_id# by interface wan,but no you  can't pipe grep output into another grep.

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
journeyman

I would very much like to be able to grep -f | grep -f in the cli, and have previously submitted a feature request.

Can anyone advise if this has been added to more recent versions of FortiOS or planned? In production we run 6.0.x and it's not there.

Does anyone have visibility of existing feature requests and their chances of implementation? Can we see them and upvote?

Yurisk
Valued Contributor

Double piping ? Not yet there, 6.4 train.

 

Yuri https://yurisk.info/  blog: All things Fortinet, no ads.
Yuri https://yurisk.info/ blog: All things Fortinet, no ads.
emnoc
Esteemed Contributor III

Yeah the easy way to do this would be 

 

show firewall policy | grep -f wan1

 

Ken Felix

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
Labels
Top Kudoed Authors