我很难从数据集中拉出用户编号和错误。我哪里出错了?从字符串中提取数字
源数据:
[319041185] :: [2013/08/28 08:10:22.702 P2D98 T020 d] PSComAccountsClient.UserPasswordVerify User=6272820002384270, Password=[not logged], AccessLevel=User
.
.
[319041253] :: [2013/08/28 08:10:22.718 P2D98 T020 e] [FunctorBase.Execute] (ErrorCode=Pedi.InternalError) An internal server error occurred. The account could not be found.
命令:
awk "{if (/User=/) {s=$NF; gsub (/[^0-9]/,\"\",s);} if (s==/[0=9]/ && /ErrorCode=/) {q=sub (/.*InternalError\\")"/,\"\"); } printf s; printf q}" file
电流输出:
NULL
预期输出:
6272820002384270 An internal server error occurred. The account could not be found.
您可以编辑以了解更多详细信息后,没有必要离开在评论细节 – krsteeve
你已经表现出一定的样本输入和你尝试的解决方案所以这是一个很好的开始,现在公布的预期输出玩完了你的问题。 –
我能够做到这一点如下: 代码: awk“{if(/ User = /){s = $ 0; sub(/.* User = /,\”\“,s); sub (/P.*/,\"\",s);} if(s &&/ErrorCode = /){sub(/.* InternalError \\“)”/,\“\”);} printf s; print} “”file“| grep”server error“| awk -F”,“”{if($ 2〜/ error /){print}}“|排序| Uniq – user2726046