免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1484 | 回复: 6
打印 上一主题 下一主题

Need Help : mask / scrabble fields in a file ? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-12-08 17:08 |只看该作者 |倒序浏览
hi, anyone can give me some advices ?
   i want to mask or scrabble certain fields(replace it as **** for example) in a log file , requirement is :
parttern one is " pin=12345664, " , the pin number is not fixed length . parttern two is " ENCRYPTED_PIN_BLOCK=12rtdsfqweweweee23w," the encrypt field length is not a fixed one as well , this two field can be appear any line in a file . can be in a same line or different line .

another problem is the log file could be huge in size . 300 M . advisable using a shell script to achieved it ?

i have attached a sample file "sample.gif"

sample.gif

6.04 KB, 下载次数: 252

sample

论坛徽章:
0
2 [报告]
发表于 2004-12-08 17:18 |只看该作者

Need Help : mask / scrabble fields in a file ?

sed 's/pin=[0-9]\{1,\}/***/' file

I cannot see your attached picture and don't quite understand your second patten.

论坛徽章:
0
3 [报告]
发表于 2004-12-08 17:21 |只看该作者

Need Help : mask / scrabble fields in a file ?

Or:
sed 's/pin=[0-9]\{1,\}/pin=***/' file

论坛徽章:
0
4 [报告]
发表于 2004-12-08 17:41 |只看该作者

Need Help : mask / scrabble fields in a file ?

thanks a lot , pls ignore the gif file .
the second pattern is "ENCRYPTED_PIN_BLOCK=****," , THE **** field could be number and alphabet , for example "229A8F53BF8DE2D771D80DD8F4E488081BD69957980" , the length is not fixed .


example line 1
[ 2001-13-14 ] *** REQUESTED *** pin=123455, Cotroller: :getResult:Request: ONWER=master tech , ENCRYPT_PIN_BLOCK=229A8F53BF8DE2D771D80DD8F4E488081BD69957980, KEY=3444

or one pattern in only one line ,

论坛徽章:
0
5 [报告]
发表于 2004-12-08 18:00 |只看该作者

Need Help : mask / scrabble fields in a file ?

OK, try this one.

sed 's/pin=[0-9]\{1,\}/pin=***/;s/ENCRYPT_PIN_BLOCK=[0-9A-Z]*,./ENCRYPT_PIN_BLOCK=****/'

论坛徽章:
0
6 [报告]
发表于 2004-12-08 18:00 |只看该作者

Need Help : mask / scrabble fields in a file ?

sed 's/pin=[0-9]\{1,\}/pin=***/;s/ENCRYPT_PIN_BLOCK=[0-9A-Z]*,./ENCRYPT_PIN_BLOCK=****/' file

论坛徽章:
0
7 [报告]
发表于 2004-12-08 18:16 |只看该作者

Need Help : mask / scrabble fields in a file ?

tested with 350M file with following time statistics :

real 225.03
user 45.58
sys  16.08

thank you so much .
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP