正则笔记

列出UA字符串:

1
zcat log.gz |awk -F '""' '{print $2}'|sed -e 's/" .{1,}//g'|head

正则回逆引用:

1
2
sed '/pattern/&/g' file
sed '/(pattern)/1/g' file

向前匹配:

1
perl -ne 'print if s/.*(?=pattern)/pattern2/' file