shell - Extracting pattern from log file in linux -


i have log file want extract 2 patterns repeating multiple times

channelrequestdailylog.log.2015-06-05: info [thread-9290] (channelrequestdailylog.java:174) - :: [iid:11][rnw:tr][rqrvt:1433477166808][rqlgt:1433477167203][rqid:4945][stv:rc][rqst:ussd][rqs:ussd][rqext:1433477167203][suid:trnp0000185881][sun:727862315][sc:new pos][sm:727862315][snw:tr][tid:r150605.0606.110013][ts:200][e:null][rm:728128482][amt:100][sst:1][rid:intid00016][val:49][top:0][cos:0][promo:0][topenq:0][promoenq:0][cosenq:0][postval:0][ppt:346][rtt:395]

pattern want see tid: , val: along text after ":".

use can use perl:

my $string =  <stdin>; chomp $string; @arr = $string =~ /\[((?:tid|val):[\w.]*)\]/g; $arr_len = scalar @arr; ( $i=0; $i<$arr_len; $i=$i+1){     print "$arr[$i]\n"; } 

output:

tid:r150605.0606.110013 val:49 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -