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
  • 相关阅读:
    Python基础07
    python基础06
    python基础05
    python基础04
    python基础03
    python基础02
    python组件之wtforms
    PythonWeb框架之Flask
    Linux下yum安装Redis
    在vuex的mutations中使用vue的小技巧
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14969695.html
Copyright © 2011-2022 走看看