測試過程當中經常使用的linux命令之【查找指定的文件內容】

    以前遇到過這種狀況,在查看日誌定位問題時,會將log 傳輸到本地,而後用本地的文本編輯工具打開文件,而後查找關鍵字,再進行分析。 這樣作無疑會下降效率。css

整理了幾個經常使用的命令,能夠進行快速的查找。正則表達式


測試文件:chrome

文件名稱爲execution.log, 文件內容以下:api

[error] Timed out after 50000mside

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

[error] Element css=#addUserBtn not found測試

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

[error] Element id=userIdList not found日誌

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

[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關鍵字的信息


grep方法

grep -i Timed execution.log  # -i,忽略大小寫

5461266c4365b94082acc50014e1d822.png


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

6cc7fa8b3209ae078a3bb0a075031334.png


vi方法

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

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

點擊n,查找下次出現的位置;點擊N,查找上一次出現的位置

87a83bc3570def607e6b2f93a456b3c0.png

相關文章
相關標籤/搜索