• linux系统中正则表达式记录


    1、[^xx] 表示取反

    root@PC1:/home/test# ls
    a.txt
    root@PC1:/home/test# cat a.txt  ## 测试数据
    333
    d g 8 3
    d g !
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# grep -v "3" a.txt   ## 只要匹配到3就排除
    d g !
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# grep "[^3]" a.txt    ## 只有全部为3才排除
    d g 8 3
    d g !
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# ls
    a.txt
    root@PC1:/home/test# cat a.txt
    333
    d g 8 3
    d g !
    555
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# grep "[^3]" a.txt
    d g 8 3
    d g !
    555
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# grep "[^35]" a.txt   ## 这里3和5是或的关系
    d g 8 3
    d g !
    _ d g
    ! ! !
    , . ?

    2、-w 表示匹配字符数字

    root@PC1:/home/test# ls
    a.txt
    root@PC1:/home/test# cat a.txt
    333
    d g 8 3
    d g !
    555
    _ d g
    ! ! !
    , . ?
    root@PC1:/home/test# grep "\w" a.txt    ## 匹配字符数字及下划线
    333
    d g 8 3
    d g !
    555
    _ d g

    -W表示匹配非字符数字:

    root@PC1:/home/test# ls
    a.txt
    root@PC1:/home/test# cat a.txt
    333
    d g 8 3
    d g !
    555
    _ d g
    !!!
    ,.?
    root@PC1:/home/test# grep "\W" a.txt   ## 匹配非字符数字及下划线
    d g 8 3
    d g !
    _ d g
    !!!
    ,.?

    3、

  • 相关阅读:
    关于Intent
    k8s常用命令
    kube-ui安装
    配置k8s dns
    centos 7 部署k8s集群
    多进程multiprocessing模块
    queue
    github安装k8s
    错误: No API token found for service account "default",
    线程
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15584037.html
Copyright © 2020-2023  润新知