========不定期更新该页面========
1、只保留匹配的内容
日志片段:
"duration":0.03,"scheme":"https","sessionId":"19B0F3DD149FF8D81A4B4D68D53569F6","userId":"60800","path":"/mobile/index.html"
sed -n ‘s/^.*\("userId":"[0-9]*"\).*$/\1/p‘ logfile.txt首先想到搞个python,后来又觉得麻烦了点,果断google得来上面的命令
python可以这样:
import re
f = open("logfile.txt")
p = re.compile(r‘"userId":"\d+"‘)
for line in f:
m = p.search(line)
print m.group(0)本文出自 “烛影摇红” 博客,请务必保留此出处http://gccmx.blog.51cto.com/479381/1611261
原文地址:http://gccmx.blog.51cto.com/479381/1611261