#!/bin/bash read -p "Enter the ip (1-254) to monitor: " -t 10 ip read -p "Enter the query (eq:.mp3 .wma) to monitor: " -t 10 query if [ "$ip" -ge "0" -a "$ip" -le "254" -a "$query" = "" ] then tail -f /var/log/squid/access.log |grep 192.168.1.${ip}|awk '{print $3 "\t" $4 "\t" $7}' elif [ "$ip" = "" -a "$query" = "" ] then tail -f /var/log/squid/access.log |awk '{print $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7}' # tail -f /var/log/squid/access.log elif [ "$ip" = "" -a "$query" != "" ] then tail -f /var/log/squid/access.log |grep $query|awk '{print $3 "\t" $7}' elif [ "$ip" -ge "0" -a "$ip" -le "254" -a "$query" != "" ] then #grep "192.168.1.$ip" /var/log/squid/access.log |grep "$query" |awk '{print $3 "\t" $4 "\t" $7}'|more tail -f /var/log/squid/access.log|grep "192.168.1.$ip" |grep "$query" |awk '{print $3 "\t" $4 "\t" $7}' elif [ "$ip" -gt "254" -a "$query" = "" ] then echo "the '$ip' is too big" elif [ "$ip" != "[0-9]" -a "$query" = "" ] then echo "you input '$ip' is not number" else echo "input error" #tail -f /var/log/squid/access.log |awk '{print $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7}' fi
针对自己需求进行更改
|