第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

返回參數(shù)sed / grep / awk / gawk中的字符串

返回參數(shù)sed / grep / awk / gawk中的字符串

慕婉清6462132 2021-04-01 13:10:23
需要一些幫助來返回2個特定定界符內(nèi)的日志文件中的所有數(shù)據(jù)。我們通常有以下日志:2018-04-17 03:59:29,243 TRACE [xml] This is just a test.2018-04-17 13:22:24,230 INFO [properties] I believe this is another test.2018-04-18 03:48:07,043 ERROR [properties] (Thread-13) UpdateType: more data coming here; ProcessId: 50102018-04-17 13:22:24,230 INFO [log] I need to retrieve this string hereand also this one as it is part of the same text2018-04-17 13:22:24,230 INFO [det] I believe this is another test.如果我將grep設(shè)為“ here”,則僅獲得包含單詞的行,但實際上我需要檢索整個文本,則中斷可能也導(dǎo)致了我的問題。2018-04-17 13:22:24,230 INFO [log] I need to retrieve this string hereand also this one as it is part of the same text我們可以在日志文件中有幾個“這里”。我試圖通過sed做到這一點,但是我找不到正確的方法來使用定界符,我認(rèn)為這應(yīng)該是整個DATE。
查看完整描述

2 回答

?
搖曳的薔薇

TA貢獻1793條經(jīng)驗 獲得超6個贊

與GNUawk多字符記錄分隔符


$ awk -v RS='(^|\n)[0-9 :,-]+' '/here/{print rs,$0} {rs=RT}' file


2018-04-18 03:48:07,043  ERROR [properties] (Thread-13) UpdateType: more data coming here; ProcessId: 5010


2018-04-17 13:22:24,230  INFO [log] I need to retrieve this string here

and also this one as it is part of the same text

注意:在這里,我通過創(chuàng)建使用時間戳記中的值的記錄分隔符來作弊。您可以精確地制定它,以消除出現(xiàn)在第二行開頭的誤報。或者,也可以將調(diào)試級別添加到匹配項中。


查看完整回答
反對 回復(fù) 2021-04-16
  • 2 回答
  • 0 關(guān)注
  • 325 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號