grep and regular expression --- ^ . *
"^" : Start of Line anchor
"." : Matches any single character except the newline character.
"*" : Matches the preceding character 0 or more times.
Application_1
test file
if_0 // no white space, no tab space
if_1 // a tab space
if_2 // two white space
command :
$ grep "^if" test
if_0
Conclusion :
^ is used to match the first column string
Application_2
test file
if_0 CROSS_COMPILE
if_1 CROSS_COMPILE
if_2 CROSS_COMPILE
command_1 :
$ grep -rns "^if.*CROSS" test
1:if_0 CROSS_COMPILE
command_2 :
$ grep -rns ".*if.*CROSS" test
1:if_0 CROSS_COMPILE
3: if_1 CROSS_COMPILE
4: if_2 CROSS_COMPILE
Conclusion :
For coding style, programmer place white or tab space in front of if.
If you want to find if as start, have to use ".*"
Application_3
test file
aaa1
aaa1
bbb2
bbb2
ccc3
ccc3
command_1 :
$ grep "^bbb" test
bbb2
bbb2
command_2 :
$ grep "^[^bbb]" test
aaa1
aaa1
ccc3
ccc3
随机推荐
- The Image Gallery Revisited
Lets apply the Best practices to the Image Gallery . /*** index.html ***/ <!DOCTYPE html> < ...
- NPM安装vue-cli,并创建vue+webpack项目模板
1.安装npm npm 是node.js 的包管理工具, 安装流程地址:https://docs.npmjs.com/cli/install 估计会非常慢,我们可以使用淘宝NPM镜像下载安装:htt ...
- CodeForces 879D Teams Formation
题意 将一个长度为\(n\)的数组重复\(m\)遍得到一个长度为\(n \times m\)的新序列,然后消掉新序列中连续\(k\)个相同的元素,不断重复这一过程,求最后剩下的序列的长度 分析 首先可 ...
- Postman-简单使用(1)
Postman-简单使用(1) Postman-简单使用 Postman-进阶使用 Postman-CI集成Jenkins Postman功能(https://www.getpostman.com/f ...
- 剑指Offer - 九度1372 - 最大子向量和(连续子数组的最大和)
剑指Offer - 九度1372 - 最大子向量和(连续子数组的最大和)2013-11-23 16:25 题目描述: HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学.今天JOBDU测试组开完会后, ...
- python - web自动化测试 - 元素操作 - 定位
# -*- coding:utf-8 -*- ''' @project: web学习 @author: Jimmy @file: find_ele.py @ide: PyCharm Community ...
- ssm项目中ueditor富文本编辑器的使用
一.下载 https://ueditor.baidu.com/website/index.html 将ueditor放到项目中合适的位置 二 . 配置文件上传路径 在utf8-jsp/jsp/conf ...
- 孤荷凌寒自学python第五十天第一次接触NoSql数据库_Firebase
孤荷凌寒自学python第五十天第一次接触NoSql数据库_Firebase (完整学习过程屏幕记录视频地址在文末) 之前对关系型数据库的学习告一段落,虽然能力所限没有能够完全完成理想中的所有数据库操 ...
- crontab-用于设置周期性被执行的指令
一个很好用的工具. 参考文章: [入门] http://baike.baidu.com/view/1229061.htm [进阶] http://blog.csdn.net/tianlesoftwar ...
- c++知识点总结--友元&运算符重载
友元函数(不属于类) 可以访问类的私有变量,以及私有函数 友元函数在类内声明需要friend关键字,类外定义就不需要 友元函数可以直接在类内定义 友元函数必须包含对象指针 友元类(不适用继承,只适 ...