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

最新文章

  1. js事件冒泡和事件捕获
  2. Chapter 4 持久存储数据对象
  3. 学习tolua#·20多个例子
  4. unity与Android交互
  5. WPF中的瀑布流布局(TilePanel)控件
  6. Redis - 排序
  7. AngularJs--过滤器(filter)
  8. [旧博客]QQ旋风加速漏洞
  9. 简单RTP发送类c++实现
  10. boost::asio网络传输错误码的一些实验结果(recv error_code)
  11. sql 两种分页offset和row_number简单分析
  12. Spring Boot Document Part II(上)
  13. Alpha阶段小结
  14. python socket.error: [Errno 24] Too many open files
  15. vs2015重新安装后,项目属性中的目标框架中没有framework4.6.1
  16. Kaggle入门(一)——Digit Recognizer
  17. 【agc019F】Yes or No
  18. Shell编程-01-Shell脚本初步入门
  19. Cookie,Sesstion,Application 缓存。
  20. 素数分布 - nefu 117

热门文章

  1. (转)JMS简明学习教程
  2. (12)centos7 环境变量配置
  3. Openstack组件实现原理 — Nova 体系结构
  4. Ubuntu 没有 无线网 RTL8821ce 8111 8186
  5. 剑指offer——44连续子数组的最大和
  6. Java内存通道
  7. No parameter name specified for argument of type
  8. Codeforces Round #527 F - Tree with Maximum Cost /// 树形DP
  9. css3 鼠标悬停图片动画
  10. robotframework+python3+selenium之下拉框的选择---第五集