测试过程中常用的linux命令之【查找指定的文件内容】
????之前遇到過這種情況,在查看日志定位問題時,會將log 傳輸到本地,然后用本地的文本編輯工具打開文件,然后查找關鍵字,再進行分析。 這樣做無疑會降低效率。
整理了幾個常用的命令,可以進行快速的查找。
測試文件:
文件名稱為execution.log, 文件內容如下:
[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關鍵字的信息
grep方法
| grep -i Timed execution.log ?# -i,忽略大小寫 |
| grep -e .*ime execution.log ? #-e, 支持正則表達式 |
vi方法
/str,正向查找,自頂向下的查找;
?str,反向查找,自底向上的查找。
點擊n,查找下次出現的位置;點擊N,查找上一次出現的位置
轉載于:https://blog.51cto.com/2338053/1978623
總結
以上是生活随笔為你收集整理的测试过程中常用的linux命令之【查找指定的文件内容】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: netty里集成spring注入mysq
- 下一篇: rhel 4/oracle linux