Linux: grep多个关键字“与”和“或”
时间 2014-05-15 01:31:47 Just Code http://www.tuicool.com/articles/6VJzI3v
原文 http://justcoding.iteye.com/blog/2066598
主题 Linux命令
1、或操作
grep -E '123|abc' filename // 找出文件(filename)中包含123或者包含abc的行
egrep '123|abc' filename // 用egrep同样可以实现
awk '/123|abc/' filename // awk 的实现方式
2、与操作
grep pattern1 files | grep pattern2 //显示既匹配 pattern1 又匹配 pattern2 的行。
3、其他操作
grep -i pattern files //不区分大小写地搜索。默认情况区分大小写,
grep -l pattern files //只列出匹配的文件名,
grep -L pattern files //列出不匹配的文件名,
grep -w pattern files //只匹配整个单词,而不是字符串的一部分(如匹配‘magic’,而不是‘magical’),
grep -C number pattern files //匹配的上下文分别显示[number]行,
curl -o /dev/null -s -w "DNS解析时间: %{time_namelookup} \n连接时间,从开始到建立TCP连接完成所用时间,包括前边DNS解析时间: %{time_connect}\n连接建立完成时间:%{time_appconnect}\n从开始到准备传输的时间: %{time_pretransfer}\n开始传输时间: %{time_starttransfer}\n总时间,按秒计: %{time_total}\n" "https://api.weixin.qq.com"
ping IP地址或主机名 [-t] [-a] [-n count] [-l size]
http:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status/502
工信部备案查询:http://www.beian.miit.gov.cn/publish/query/indexFirst.action
ip地址查询:http://www.chacuo.net/
charles 工具