- 论坛徽章:
- 0
|
本帖最后由 qmqpfi 于 2012-02-19 23:46 编辑
回复 6# rdcwayx
不好意思,发现还有一个小问题,一直试不出来
……
path=/apache/access/log/
host=$1
case $type in
"user")
cat $file | grep $type | awk '/GET/&&/user.php\?uid=/{split($7,a,"[/|.|?|=|&]");print $1,substr($4,2),$NF > /a[3]"."a[8]".log"}'
;;
"port")
cat $file | grep $type | awk -F " " '{print $1,substr($4,2),$NF}' >> $path$type.log # 这里的$path起作用了
;;
esac
……
1、想把输出的文件指定到$path下,如:
/apache/access/log/user.baidu.log
2、把$host(192.168.1.1)的内容添加到输出文件的内容里面,就是在awk筛选出来的结果前加入$host的内容,如:
192.168.1.1 111.111.111.111 14/Feb/2012:00:02:32 35622
我直接把$path和$host放到awk里面,但是执行不了提示错误,实在没办法了。
请指点一下我该怎么改写,谢谢!
周末买了本<Shell脚本学习指南>,以后慢慢学习一下这个精悍而又强大的Shell |
|