Hot!grep the grep command on CLI ?

Author
FlashOver
Gold Member
  • Total Posts : 153
  • Scores: 0
  • Reward points: 0
  • Joined: 2007/09/13 04:42:08
  • Status: offline
2013/11/22 12:05:56 (permalink)
0

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?
#1

7 Replies Related Threads

    ede_pfau
    Expert Member
    • Total Posts : 6383
    • Scores: 547
    • Reward points: 0
    • Joined: 2004/03/09 01:20:18
    • Location: Heidelberg, Germany
    • Status: offline
    RE: grep the grep command on CLI ? 2013/11/23 03:36:59 (permalink)
    0
    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!"
    #2
    emnoc
    Expert Member
    • Total Posts : 5860
    • Scores: 387
    • Reward points: 0
    • Joined: 2008/03/20 13:30:33
    • Location: AUSTIN TX AREA
    • Status: online
    RE: grep the grep command on CLI ? 2013/11/23 07:40:02 (permalink)
    0
    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  
    #3
    fropert_FTNT
    Bronze Member
    • Total Posts : 26
    • Scores: 2
    • Reward points: 0
    • Joined: 2011/10/23 08:33:44
    • Location: Fortinet PSIRT
    • Status: offline
    RE: grep the grep command on CLI ? 2013/11/23 12:17:47 (permalink)
    0
    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
    #4
    emnoc
    Expert Member
    • Total Posts : 5860
    • Scores: 387
    • Reward points: 0
    • Joined: 2008/03/20 13:30:33
    • Location: AUSTIN TX AREA
    • Status: online
    Re: RE: grep the grep command on CLI ? 2018/02/02 17:22:36 (permalink)
    0
    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  
    #5
    journeyman
    Gold Member
    • Total Posts : 174
    • Scores: 0
    • Reward points: 0
    • Joined: 2011/03/15 22:56:36
    • Status: offline
    Re: RE: grep the grep command on CLI ? 2020/09/03 17:51:48 (permalink)
    0
    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?
    post edited by journeyman - 2020/09/03 17:57:47
    #6
    Yurisk
    Silver Member
    • Total Posts : 114
    • Scores: 22
    • Reward points: 0
    • Joined: 2011/12/04 03:30:01
    • Status: offline
    Re: RE: grep the grep command on CLI ? 2020/09/03 22:42:28 (permalink)
    0
    Double piping ? Not yet there, 6.4 train.
     
    #7
    emnoc
    Expert Member
    • Total Posts : 5860
    • Scores: 387
    • Reward points: 0
    • Joined: 2008/03/20 13:30:33
    • Location: AUSTIN TX AREA
    • Status: online
    Re: grep the grep command on CLI ? 2020/11/20 16:08:28 (permalink)
    0
    Yeah the easy way to do this would be 
     
    show firewall policy | grep -f wan1
     
    Ken Felix

    PCNSE 
    NSE 
    StrongSwan  
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 5.5