您的位置:首页 > 其它

统计user

2015-06-28 15:12 183 查看
#!/bin/ksh

logpath=/home/felixzh

execpath=/opt/cool/.logs

#redirect stdout/stderr to file

exec 2>&1

exec 1> /home/felixzh/$1

#use function

function readfile

{

filename=$1

y=$2

>$logpath/$y.name

while read line1

do

#use nawk to split line

user=`echo $line1|nawk -F ';' '{print $1}'`

#use >/dev/null or -q ,stop result output to files

grep $user $logpath/$y.name >/dev/null

#grep -q $user $logpath/$y.name

if [ $? != 0 ]

then

echo $user >>$logpath/$y.name

fi

done <$filename

#static lines for file

i=`wc -l $execpath/$filename`

j=`wc -l $logpath/$y.name`

echo "i=$i"

echo "j=$j"

}

function usage

{

echo "./static 2014"

}

if [ $# -lt 1 ]

then

usage

exit

fi

cd $execpath

ls -ltr use* >$logpath/1

year=$1

while read line

do

time=`echo $line |nawk '{print $8}'`

if [ "$time" == "$year" ]

then

name=`echo $line |nawk '{print $9}'`

readfile $name $year

fi

done <$logpath/1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: