1. 打印第一次出现指定时间戳的行号:
grep -n -m1 "2017-06-24T09" click.log_manual_del_1
2. 目录递归搜索文件中出现 this.js 这样的内容的地方:
grep -r "this.js" *
3. 查找不是以 h 开头的行 并且显示其后面的1行 -》处理 redis 导出的文件 :
grep -v -E "^h" -a1 camprate_dick.txt
4. 过滤日志中的指定机型 (这个是之前写的,现在感觉写的乱了点额):
grep -v -E "Mozilla/5.0 \(iPhone; CPU iPhone OS .* like Mac OS X\) AppleWebKit/.*\(KHTML, like Gecko\) Mobile/.*" click.log_2017-05-07T23 | grep -v -E "Mozilla/5.0 \(iPhone; CPU iPhone OS .* like Mac OS X\) AppleWebKit/.* \(KHTML, like Gecko\) Version/.* Mobile/.* Safari/\d{3}\.\d" > notAll.txt
grep -e "Mozilla/5.0 \(iPhone; CPU iPhone OS .* like Mac OS X\) AppleWebKit/.*\(KHTML, like Gecko\) Mobile/.*" click.log_2017-05-07T23
ag -e "Mozilla/5.0 \(iPhone; CPU iPhone OS .* like Mac OS X\) AppleWebKit/.*\(KHTML, like Gecko\) Mobile/.*" click.log_2017-05-07T23