【Linux学习笔记】9:字符串搜索命令grep
来源:互联网 发布:建立客户档案软件 编辑:程序博客网 时间:2024/05/29 02:19
grep搜索字符串
用于在文件中搜索符合条件的字符串所在行。
grep [-i -v] 字符串 文件名
选项:-i不区分大小写,-v排除指定字符串(不包含它的)。
如在安装日志中查找有”size”的行(我这个系统没有手动分区,这个结果和视频里那种手动分区的会不同):
[root@bogon ~]# grep "size" anaconda-ks.cfg #volgroup VolGroup --pesize=4096 pv.008002#logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200#logvol swap --name=lv_swap --vgname=VolGroup --grow --size=4032 --maxsize=4032#part /boot --fstype=ext4 --size=500#part pv.008002 --grow --size=1
又如查找不包含”size”的行:
[root@bogon ~]# grep -v "size" anaconda-ks.cfg# Kickstart file automatically generated by anaconda.#version=DEVELinstallcdromlang zh_CN.UTF-8keyboard usnetwork --onboot no --device eth0 --bootproto dhcp --noipv6rootpw --iscrypted $6$.NzYMwlF4dkuqqEZ$D3Q4PYMZrA9ReI7PwSb5r19VdbAMkdE.cEW0gA8NUwq/dhyQQPUZ2EAbs2e4XUY5ofyW80F0qwnacQJvIQ.OU.firewall --service=sshauthconfig --enableshadow --passalgo=sha512selinux --enforcingtimezone --utc Asia/Shanghaibootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"# The following is the partition information you requested# Note that any partitions you deleted are not expressed# here so unless you clear all partitions first, this is# not guaranteed to work#clearpart --all --drives=sda%packages@base@chinese-support@client-mgmt-tools@console-internet@core@debugging@directory-client@hardware-monitoring@java-platform@large-systems@network-file-system-client@performance@perl-runtime@server-platform@server-policypaxpython-dmidecodeoddjobsgpiodevice-mapper-persistent-datasamba-winbindcertmongerpam_krb5krb5-workstationperl-DBD-SQLite%end
注意find匹配的是文件,但是grep匹配的是文件中的行,只要包含有那个字符串,就会把这一行列出来。find可以使用通配符,grep可以使用正则表达式,从而进行更复杂的匹配。
阅读全文
0 0
- 【Linux学习笔记】9:字符串搜索命令grep
- Linux学习笔记--grep命令(搜索字符串命令)
- Linux 字符串搜索命令 grep
- linux 文件中搜索字符串命令 grep
- linux 文件中搜索字符串命令 grep
- linux 文件中搜索字符串命令 grep
- linux 文件中搜索字符串命令 grep
- linux中grep字符串搜索命令
- grep 搜索字符串命令
- grep 搜索字符串命令
- 字符串搜索命令grep
- 字符串搜索命令 grep
- grep命令---Linux学习笔记
- linux学习笔记—grep命令
- Linux命令学习笔记之grep
- Linux 学习笔记(十、搜索字符串命令)
- linux下搜索字符串 grep
- linux之grep搜索字符串
- [[Prototype]]--浅析
- 【Linux】常用命令总结
- 【LeetCode】 7. Reverse Integer
- JAVASE基础(十三)
- Linux使用mdadm模拟RAID5磁盘阵列
- 【Linux学习笔记】9:字符串搜索命令grep
- java学习2:记录如何简单的将idea编写的程序打包并转为exe格式
- 栈、队列(1)
- 【C语言】【unix c】文件的重定向
- mybatis入门之接口式编程
- Mock测试工具比较
- CentOS 7 更新源 – 使用国内 163 yum 源 [日期:2015-09-22]来源:imcn.me 作者:Linux[字体:大 中 小] 突然想起试试 Docker,在一台计算机上
- 【C语言】【unix c】文件锁的使用
- androidstudio 获取百度地图开发版SHA1值