分类:
2010-03-24 16:34:46
#!/bin/bash ##for * ipadress segment##
source_file=target_file=ip_area=_AGGR=/usr/bin/aggregateAGGR="$_AGGR -q -m 30 -o 30"
usage(){ cat < Usage: $(basename $0) [-f source file ] [ -t target file ] [-a area] EOF1}
utf8_ip_area(){ iconv -c -f gb2312 -t utf-8 $1 | grep "$ip_area" | awk '{print $1,$2}' }
while [ -n "$1" ]; do case "$1" in "-f"|"--sfile") shift source_file=$1 shift ;; "-t"|"--tfile") shift target_file=$1 shift ;; "-a"|"--iparea") shift ip_area=$1 shift ;; *) echo "Error: Invalid argument" usage exit 1 ;; esacdone
[ -z "$source_file" -o -z "$target_file" -o -z "$ip_area" ] && usage && exit 2
[ ! -x "$_AGGR" ] && echo "Cannot find $_AGGR" && exit 3
utf8_ip_area $source_file > testawhile read a ;do ipcalc -r $a |grep ^[0-9] #ipcalc -r $a |grep ^[0-9] >> b.txt #i=`ipcalc -r $a |grep ^[0-9] |wc -l` #[ "$i" -gt 1 ] && echo $adone < testa | $AGGR > $target_filerm testa
阅读(903) | 评论(0) | 转发(0) |