zoukankan      html  css  js  c++  java
  • grep 命令使用指南

                                          grep 命令                                           

    grep参数:

    -E:等同于egrep

    -o:只匹配你想要的内容,下面是示例:

    [root@localhost ~]# cat /data/game/config/server_config.txt | grep mysql_port | egrep -o "[0-9]+"
    3306
    [root@localhost ~]# cat /data/game/config/server_config.txt | grep mysql_port | egrep "[0-9]+"
    {mysql_port, 3306}.

    使用grep命令进行多个条件查询:
    [root@TX-2 tmp]# cat a.txt error error error error error ERROR ERROR ERROR ERROR ERROR ERROR ERROR [root@TX-2 tmp]# cat a.txt | grep -E "error|ERROR" error error error error error ERROR ERROR ERROR ERROR ERROR ERROR ERROR [root@TX-2 tmp]#
    使用grep匹配ip地址:
    [root@localhost ~]# egrep "[0-9]+.[0-9]+.[0-9]+.[0-9]+." a 123.123.123.123 123.123.123 [root@localhost ~]# egrep "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}." a 123.123.123.123 123.123.123
  • 相关阅读:
    jquery学习笔记1
    javascript常用函数(1):jquery操作select 基本操作
    Angular.js学习笔记
    Mutex, semaphore, spinlock
    Linq 常用方法解释
    装B必备之 快捷键配置
    HttpWebRequest
    HttpClient get post
    js获取url 参数
    整洁代码1
  • 原文地址:https://www.cnblogs.com/tangshengwei/p/5026403.html
Copyright © 2011-2022 走看看