X-Git-Url: http://gitweb.pimeys.fr/?p=scripts-20-100.git;a=blobdiff_plain;f=grepmac.sh;h=2f8c051ba421b1a6376fa106a5e3139349bd291f;hp=046229a6798a0f3cc40d53af703bedda7fef4f6b;hb=9ad2a272dd90a939590df3881cbe98ad174d1214;hpb=2d7cd8502b1d458af1c6994d6f983560aa7b6e6a diff --git a/grepmac.sh b/grepmac.sh index 046229a..2f8c051 100755 --- a/grepmac.sh +++ b/grepmac.sh @@ -4,7 +4,7 @@ filename=global -# On ne va pas chercher au même endroit en fonction du serveur +# On râle si on n'est pas sur le bon serveur case `hostname` in thot) ;; @@ -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