zoukankan      html  css  js  c++  java
  • linux系统中grep同时提取以特定字符开头的行、以特定字符结尾的行

    1、

    [root@centos79 test]# cat a.txt
    a g r e
    u c j alike
    i x k like
    a f g liker
    a f h g liker
    s g e g
    [root@centos79 test]# grep "^a" a.txt   ## 查找以a开头的行
    a g r e
    a f g liker
    a f h g liker
    [root@centos79 test]# grep "^a.*r$" a.txt   ## 同时查找以a开头同时以r结尾的行
    a f g liker
    a f h g liker
    [root@centos79 test]# grep "^a.*h.*r$" a.txt  ## 同时查找以a开头,包含字符h,并以r结尾的行
    a f h g liker

    2、

    [root@centos79 test]# cat a.txt
    a g r e
    u c j alike
    i x k like
    a f g liker
    a f h g liker
    s g e g
    [root@centos79 test]# grep "^a|e$" a.txt  ## 提取以a开头,或者以e结尾的行
    a g r e
    u c j alike
    i x k like
    a f g liker
    a f h g liker
  • 相关阅读:
    hashlib模块
    logging模块
    Python的富比较方法
    格式化符号说明
    __str__与__repr__区别
    2014-07-18 10:25

    2014-07-17 17:04
    2014-07-17 16:44
    2014-07-16 15:54
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14969695.html
Copyright © 2011-2022 走看看