zoukankan      html  css  js  c++  java
  • linux中grep命令锚定锚定单词的词首、词尾

    1、测试数据

    [root@centos79 test]# cat a.txt
    a g e
    u c j alike
    i x k like
    w f g liker
    s g e g
    [root@centos79 test]# grep like a.txt
    u c j alike
    i x k like
    w f g liker

    2、、B锚定单词的词首

    [root@centos79 test]# cat a.txt
    a g e
    u c j alike
    i x k like
    w f g liker
    s g e g
    [root@centos79 test]# grep "like" a.txt
    u c j alike
    i x k like
    w f g liker
    [root@centos79 test]# grep "like" a.txt
    i x k like
    w f g liker
    [root@centos79 test]# grep "Blike" a.txt
    u c j alike

    3、、B锚定词尾

    [root@centos79 test]# cat a.txt
    a g e
    u c j alike
    i x k like
    w f g liker
    s g e g
    [root@centos79 test]# grep "like" a.txt
    u c j alike
    i x k like
    w f g liker
    [root@centos79 test]# grep "like" a.txt
    u c j alike
    i x k like
    [root@centos79 test]# grep "likeB" a.txt
    w f g liker

    4、同时锚定词首和词尾

    [root@centos79 test]# cat a.txt
    a g e
    u c j alike
    i x k like
    w f g liker
    s g e g
    [root@centos79 test]# grep "like" a.txt
    u c j alike
    i x k like
    w f g liker
    [root@centos79 test]# grep "like" a.txt
    i x k like
    [root@centos79 test]# grep -w "like" a.txt
    i x k like

    5、

    [root@centos79 test]# cat a.txt
    a g e
    u c j alike
    i x k like
    w f g liker
    s g e g
    [root@centos79 test]# grep "<like" a.txt
    i x k like
    w f g liker
    [root@centos79 test]# grep "like>" a.txt
    u c j alike
    i x k like
    [root@centos79 test]# grep "<like>" a.txt
    i x k like

    参考:https://www.cnblogs.com/flyor/p/6411140.html

  • 相关阅读:
    php+apache+mysql环境搭建
    怎么理解依赖注入
    maven修改远程和本地仓库地址
    idea创建的java web项目打包发布到tomcat
    MYSQL 导入导出数据库文件
    MySQL约束
    mysql字符集校对
    prime
    POJ-2564 01背包问题
    POJ-1564 dfs
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14969625.html
Copyright © 2011-2022 走看看