zoukankan      html  css  js  c++  java
  • Centos之字符串搜索命令grep

    grep [选项] 字符串 文件名

    在文件当中匹配符合条件的字符串

    选项:

    -i 忽略大小写

    -v 排除指定字符串

    [root@localhost ~]# grep "work" anaconda-ks.cfg 

    # Network information

    network  --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate

    network  --hostname=localhost.localdomain

    [root@localhost ~]# 

    我们可以找到anaconda-ks.cfg 文件中含有"work"字符串的行

    [root@localhost ~]# grep -v  "work" anaconda-ks.cfg 

    #version=DEVEL

    #sdfsddsd

     System authorization information

    auth --enableshadow --passalgo=sha512

    # Use CDROM installation media

    cdrom

    # Use graphical install

    graphical

    # Run the Setup Agent on first boot

    firstboot --enable

    # Keyboard layouts

    keyboard --vckeymap=cn --xlayouts='cn'

    # System language

    lang zh_CN.UTF-8

    # Root password

    rootpw --iscrypted $6$G7eVijyXAp8DMSXi$bKh/vjEbEdH.4WmgXjhpw08/jYzjGDgaTnc8ZNFfUREgFX0Kepz39OwQsjhlFBaYUPwUUuI.RcsCAgkqrWeSJ1

    # System services

    services --disabled="chronyd"

    # System timezone

    timezone Asia/Shanghai --isUtc --nontp

    # System bootloader configuration

    bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda

    autopart --type=lvm

    # Partition clearing information

    clearpart --none --initlabel

    %packages

    @^minimal

    @core

    kexec-tools

    %end

    %addon com_redhat_kdump --enable --reserve-mb='auto'

    %end

    %anaconda

    pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty

    pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty

    pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty

    %end

    [root@localhost ~]# 

    加了 -v 就查找不包含"work"的行;

  • 相关阅读:
    软件测试 (三) 界面测试
    软件测试 (二) 六年软件测试感悟
    软件测试 (一) 软件测试方法大汇总
    第二阶段站立会议6
    第二阶段站立会议5
    构建之法阅读笔记04
    第二阶段站立会议4
    第二阶段站立会议3
    第二阶段站立会议2
    第二阶段站立会议1
  • 原文地址:https://www.cnblogs.com/wishwzp/p/7113346.html
Copyright © 2011-2022 走看看