Skip to main content

01 | GREP

De FortiGate CLI biedt een ingebouwde versie van het grep-commando waarmee je output efficiënt kunt filteren.

GREP | Opties

Usage: grep [-invfcABC] PATTERN
Options:
        -i      Ignore case distinctions
        -n      Print line number with output lines
        -v      Select non-matching lines
        -f      Print fortinet config context
        -c      Only print count of matching lines
        -A      Print NUM lines of trailing context
        -B      Print NUM lines of leading context
        -C      Print NUM lines of output context

GREP | Simpele query

Met een simpele GREP query kan je zien of de waarde voor komt in de config

LNNLROSEBFW001 (JP) # show sys int | grep VLAN2001
    edit "VLAN2001"

GREP | Configuratie blok query

Door middel van de -f flag kan je de volledige config zien van waar de waarde in voor komt

LNNLROSEBFW001 (JP) # show sys int | grep -f VLAN2001
config system interface
    edit "VLAN2001" <---
        set vdom "JP"
        set ip 10.20.1.254 255.255.255.0
        set alias "Intern VLAN"
        set device-identification enable
        set monitor-bandwidth enable
        set role lan
        set interface "ae1"
        set vlanid 2001
    next
end

GREP | Meerdere waardes

Door middel van '<waarde1>\|<waarde2>' kan je meerdere waardes opvragen, hierbij kan je uiteraard ook weer de -f flag gebruiken

LNNLROSEBFW001 (JP) # show sys int | grep 'VLAN2001\|VLAN2002'
    edit "VLAN2001"
    edit "VLAN2002"