24-Ubuntu-文件和目录命令-查找文件内容-grep
2024-08-26 22:06:19
grep
- Linux系统中grep命令是一种强大的文本搜索工具.
- grep允许文本文件进行模式查找,所谓模式查找,又被称为正则表达式.
选项 | 含义 |
-n | 显示匹配行及行号 |
-v | 显示不包括匹配文本的所有行(相当于取反) |
-i | 忽略大小写 |
1.查找所有'hello world'出现的行号
grep -n 'hello world' demo.txt
2.大小写查找所有'hello world'出现的行号
grep -ni 'hello world' demo.txt
3.查找'hello world'没有出现的行号
grep -vn 'hello world' demo.txt
常用的两种模式查找:
参数 | 含义 |
^a | ^匹配字符串行首,搜寻以a开头的行 |
ke$ | $匹配字符串行尾,搜寻以ke结束的行 |
4.查找以fk开头的行及其行号;以fj结尾的行及其行号(模式查找).
grep -n ^fk demo.txt
grep -n fj$ demo.txt
最新文章
- js事件冒泡和事件捕获
- Chapter 4 持久存储数据对象
- 学习tolua#·20多个例子
- unity与Android交互
- WPF中的瀑布流布局(TilePanel)控件
- Redis - 排序
- AngularJs--过滤器(filter)
- [旧博客]QQ旋风加速漏洞
- 简单RTP发送类c++实现
- boost::asio网络传输错误码的一些实验结果(recv error_code)
- sql 两种分页offset和row_number简单分析
- Spring Boot Document Part II(上)
- Alpha阶段小结
- python socket.error: [Errno 24] Too many open files
- vs2015重新安装后,项目属性中的目标框架中没有framework4.6.1
- Kaggle入门(一)——Digit Recognizer
- 【agc019F】Yes or No
- Shell编程-01-Shell脚本初步入门
- Cookie,Sesstion,Application 缓存。
- 素数分布 - nefu 117
热门文章
- (转)JMS简明学习教程
- (12)centos7 环境变量配置
- Openstack组件实现原理 — Nova 体系结构
- Ubuntu 没有 无线网 RTL8821ce 8111 8186
- 剑指offer——44连续子数组的最大和
- Java内存通道
- No parameter name specified for argument of type
- Codeforces Round #527 F - Tree with Maximum Cost /// 树形DP
- css3 鼠标悬停图片动画
- robotframework+python3+selenium之下拉框的选择---第五集