- 论坛徽章:
- 0
|
本帖最后由 molaifeng 于 2012-10-24 16:16 编辑
大家好,我在/var/asg/log/confRec/ 路径下放了三个这样的文件conference20121012.rec conference20121018.rec conference20121019.rec,文件里的内容大致为如下样式
- 1350551303:2001:2003 was set to unmute
- 1350551304:2001:2002 was set to unmute
- 1350551307:2001:2002 was kicked out from conference
- 1350551308:2001:2002 was left conference
- 1350551310:2001:2002 was invited to join the conference
- 1350551311:2001:2002 was join in conference
- 1350551349:2001:2002 was set to unmute
- 1350551369:2001:2002 was set to mute
- 1350551415:2001:conference end
- 1350551416:2001:2002 was left conference
- 1350551416:2001:2003 was left conference
复制代码 我写了个shell脚本
- #!/bin/sh
- path="/var/asg/log/confRec/";
- function queryData()
- {
- if [ ! -d $path ]
- then
- echo ""
- exit
- fi
- sdate=`echo $1 | cut -d: -f1`
- edate=`echo $1 | cut -d: -f2`
- num=`echo $1 | cut -d: -f3`
- file=`ls $path | grep [0-9]`
-
-
- for x in $file
- do
- tac $x | awk -v num=$num 'BEGIN{
- FS=":";
- }
- {
- if( (num!="" && $2==num) || num=="" ){
- printf("%s\n",$0);
- }
- }'
- done
- }
- #
- # main routine
- #
- action="$1"
- setting="$2"
- case $action in
- query_data)
- queryData $setting
- ;;
- *)
- ;;
- esac
复制代码 本来是想实现查询在开始时间到结束时间之内文件的内容的,可是第一步都显示不出来,也就是在文件内按字段查询,是不是哪里出现了问题 |
|