X-Git-Url: http://gitweb.pimeys.fr/?p=scripts-20-100.git;a=blobdiff_plain;f=grepmac.sh;h=2f8c051ba421b1a6376fa106a5e3139349bd291f;hp=b31a56cc27afa2aff544e423602ca8e2cc1d0d43;hb=ae1c96ff21bdfe773fab67a92d3404d13d616dce;hpb=207b3d996873b55a0a712d754405a2b521022b6c diff --git a/grepmac.sh b/grepmac.sh index b31a56c..2f8c051 100755 --- a/grepmac.sh +++ b/grepmac.sh @@ -20,18 +20,31 @@ case $1 in --wifi) path=/var/log/wifi/ ;; + *) + echo "Préciser --filaire ou --wifi en premier paramètre." esac # On remplace les ":" de la MAC par des "." -mac=${2//:/.} +# cela permet de parser aa:aa:aa:aa:aa:aa et AA-AA-AA-AA-AA-AA +mac1=${2//:/.} + +# On prévoit aussi de parser le format AAAAAAAAAAAA (certains logs des switchs (tags de VLAN)) +mac2=${2//:/} + +# Format AAAAAA-AAAAAA (d'autres logs des switchs) +mac3="${mac2:0:6}-${mac2:6:6}" + +# On merge +mac="(${mac1}|${mac2}|${mac3})" # .log et .log.1 ne sont pas compressés -grep --color -i $mac $path$filename.log +echo grep -E --color -i $mac $path$filename.log +grep -E --color -i $mac $path$filename.log # Les suivants sont compressés for i in `seq 1 364` do echo -n ".$i ?" read -r - zgrep --color -i $mac $path$filename.log.$i.gz + zgrep -E --color -i $mac $path$filename.log.$i.gz done