Linux命令-grep
- grep命令用于对文本进行搜索,格式为“grep [选项] [文件]”
- 搜索某个关键词:"grep 关键词 文本文件"
- 参数说明
-b 将可执行文件当做文本文件来搜索
-c 仅显示找到的次数
-i 忽略大小写
-n 显示行号
-v 反向选择
- 实例1:
文本文件:
[root@localhost testA]# cat .txt
Welcome to linuxprobe.com
Red Hat certified
Free Linux Lessons
Professional guidance
Linux Course
[root@localhost testA]# 进行搜索: [root@localhost testA]# grep Linux 111.txt
Free Linux Lessons
Linux Course [root@localhost testA]# grep -n Linux 111.txt
3:Free Linux Lessons
5:Linux Course [root@localhost testA]# grep -i -n Linux 111.txt
1:Welcome to linuxprobe.com
3:Free Linux Lessons
5:Linux Course [root@localhost testA]# grep -i -n -v Linux 111.txt
2:Red Hat certified
4:Professional guidance [root@localhost testA]# grep -i -n -v -c Linux 111.txt
2
- 实例2:查找111.txt中不包含大写或小写linux的行,并输出到同目录下的123.txt文件中
[root@localhost testA]# grep -n -v -i linux .txt >> /root/testA/.txt
[root@localhost testA]# cat .txt
:Red Hat certified
:Professional guidance
Linux命令-grep的更多相关文章
- linux 命令grep
linux 命令grep grep命令用来搜索文本,或从给定的文件中搜索行内包含了给定字符串或单词的文件.通常来说,grep显示匹配的行.使用grep来搜索包括一个或多个正则表达式匹配到的文本行,然后 ...
- 【linux】linux命令grep + awk 详解
linux命令grep + awk 详解 grep:https://www.cnblogs.com/flyor/p/6411140.html awk:https://www.cnblogs.com ...
- Linux 命令 - grep: 正则搜索文本
grep 搜索文本文件中与指定正则表达式匹配的行 命令格式 grep [OPTIONS] PATTERN [FILE...] 命令参数 Generic Program Information --he ...
- Linux 命令——grep | 正则表达式
感觉讲的很详细,瞬间懂了grep,正则. from: here 简介 grep (global search regular expression(RE) and print out the line ...
- 菜鸟学Linux命令:grep配合ls等使用
linux grep命令 (global search regular expression(RE) and print out the line )是一种强大的文本搜索工具,它能使用正则表达式搜索文 ...
- (转)Linux命令grep
场景:grep命令在文件搜索中经常会使用到,所以熟练掌握该命令对于日常日志搜索相当有必要! Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.g ...
- [ Linux 命令 ] grep
一.grep是什么? Linux grep命令是用于查找文件里符合条件行的shell命令. 二.为什么要使用grep? 在查找文件内容时候,通过使用grep指定条件,可以快速定位到文件里字符串所在的行 ...
- 日志快速筛选 之 linux命令grep|uniq|wc|awk
以前我个人的观念是,在线上运行的东西尽量不要记什么流水日志. 但是后来我变了,发现在线上记日志是一个绝对有必要的东西,尤其是在当下很流行的微服务的推动下,没有日志的帮助,犹如一个睁眼瞎,排查问题基本靠 ...
- linux命令-grep+正则表达式用法
目标文件/etc/passwd,使用grep命令或egrep 1.显示出所有含有root的行:egrep 'root' passwd 2.输出任何包含bash的所有行,还要输出紧接着这行的上下各两行的 ...
随机推荐
- Android -- 资源使用和总结经验分享
颜色资源 颜色XML文件格式 ...
- 寻找idea...
域名:tianhuangdilao.com 天荒地老 现在闲置,寻求好的idea...
- Web前端一种动态样式语言-- Less
变量 变量允许我们单独定义一系列通用的样式,然后在需要的时候去调用.所以在做全局样式调整的时候我们可能只需要修改几行代码就可以了. // LESS @color: #4D926F; #header { ...
- 6、android 普通日志输出到SD卡
这是本人见过写博文最负责的一个人: http://www.crifan.com/android_try_use_android_logging_log4j_to_output_log_to_sd_ca ...
- web项目自动化测试方案预研
一. 网上方案整理 Watir.Watir-Webdriver.Selenium2.QTP区别 Waitr与Watir-WebDriver有什么区别? Watir是非常优秀的一款自动化测试工具.其使 ...
- javascript_04 数据类型
ECMAScript 数据类型 标准 核心 数据类型 typeof 判断数据类型 数字型 布尔型 对象类型 函数 字符串 undefined 未定义 数字型 字符型 var s='1233 ...
- Json Serialize 忽略特定属性
Json Serialize 忽略特定属性 Json Serialize SerializeFilter 忽略特定属性 key words:Json Serialize jackson fastjso ...
- fullscreen DXGI DX11
these days i am fullfilling full screen https://github.com/rufelt/simpled3d11window put this one in ...
- 引擎设计跟踪(九.14.2i) Android GLES 3.0 完善
最近把渲染设备对应的GLES的API填上了. 主要有IRenderDevice/IShader/ITexture/IGraphicsResourceManager/IIndexBuffer/IVert ...
- 说说php取余运算(%)的那点事
http://www.phpddt.com/php/php-take-over.html fmod()与 % 区别 都是取余 fmod是函数 原型float fmod(float x, ...