溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

測(cè)試過(guò)程中常用的linux命令之【查找指定的文件內(nèi)容】

發(fā)布時(shí)間:2020-08-11 05:41:26 來(lái)源:網(wǎng)絡(luò) 閱讀:598 作者:ilanqing 欄目:軟件技術(shù)

    之前遇到過(guò)這種情況,在查看日志定位問(wèn)題時(shí),會(huì)將log 傳輸?shù)奖镜?,然后用本地的文本編輯工具打開(kāi)文件,然后查找關(guān)鍵字,再進(jìn)行分析。 這樣做無(wú)疑會(huì)降低效率。

整理了幾個(gè)常用的命令,可以進(jìn)行快速的查找。


測(cè)試文件:

文件名稱(chēng)為execution.log, 文件內(nèi)容如下:

[error] Timed out after 50000ms

[error] Element css=#href_20_Id > span.title not found

[error] Element css=#addUserBtn not found

[error] Element css=td[title="13011094548"] not found

[error] Element id=userIdList not found

[error] Element css=div.toast.toast-success not found

[error] There was an unexpected Alert! 

[error] Element name=id[] not found

[error] Element xpath=//table/tbody/tr/td[3] not found

[error] Element css=div.toast-message not found

[error] Unexpected Exception: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIFileOutputStream.init]"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js :: newFileOutputStream :: line 3112"  data: no]. toString -> function toString() {

需求:查找Timed關(guān)鍵字的信息


grep方法

grep -i Timed execution.log  # -i,忽略大小寫(xiě)

測(cè)試過(guò)程中常用的linux命令之【查找指定的文件內(nèi)容】


grep -e .*ime execution.log   #-e, 支持正則表達(dá)式

測(cè)試過(guò)程中常用的linux命令之【查找指定的文件內(nèi)容】


vi方法

/str,正向查找,自頂向下的查找;

?str,反向查找,自底向上的查找。

點(diǎn)擊n,查找下次出現(xiàn)的位置;點(diǎn)擊N,查找上一次出現(xiàn)的位置

測(cè)試過(guò)程中常用的linux命令之【查找指定的文件內(nèi)容】

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI