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]
curl '
http://umc.danuoyi.alicdn.com/multi_dns_resolve?client_ip=182.92.253.16' -d 'd.tv.taobao.com'
http:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status/502工信部備案查詢:
http://www.beian.miit.gov.cn/publish/query/indexFirst.actionip位址查詢:
http://www.chacuo.net/charles 工具