温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

测试过程中常用的linux命令之【查找指定的文件内容】

发布时间:2020-08-11 05:41:26 来源:网络 阅读:596 作者:ilanqing 栏目:软件技术

    之前遇到过这种情况,在查看日志定位问题时,会将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,忽略大小写

测试过程中常用的linux命令之【查找指定的文件内容】


grep -e .*ime execution.log   #-e, 支持正则表达式

测试过程中常用的linux命令之【查找指定的文件内容】


vi方法

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

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

点击n,查找下次出现的位置;点击N,查找上一次出现的位置

测试过程中常用的linux命令之【查找指定的文件内容】

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI