"^" : 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

随机推荐

  1. cocos2d-x 3.0的入门程序:helloworld

    看过了这么多不同方向的应用,发现很多程序入门都是helloworldhelloworld是所有程序员的绝对初恋 先看一下程序的运行结果吧 然后就是他的工程代码 工程的目录有两个 Classes:程序中 ...

  2. 关于android 5.0报错:dlopen failed: couldn't map ... Permission denied

    问题描述: 我的应用当中集成了一个安全相关的sdk,而这个sdk中使用的so是加过壳的. 它加载native so的方式是:Java System.loadLibrary --> native ...

  3. Pascal小游戏 随机函数

    一个被人写滥了的小程序,新手学习,Pascal By Chaobs 初学者可以用它来学习随机函数的运用,当然你完全可以自己写一个随机函数. var   player1,player2:longint; ...

  4. [转载]python 变量命名规范

    原文地址:python 变量命名规范作者:loveflying python源码和其他一些书籍,命名各种个性,没有一个比较统一的命名规范.于是自己总结了一些,可供参考. 模块名: 小写字母,单词之间用 ...

  5. WordCount 基础功能

    软测第一次作业 该项目在码云上的地址: https://gitee.com/zhege/WordCount 一,概述 WordCount的基础功能需求分析大致如下:对程序设计语言源文件统计字符数.单词 ...

  6. selenium初识(二)——之webdriver API

    配置完的环境之后,我们先来写一个小脚本: # __Author__:"Jim_xie" from selenium import webdriver from time impor ...

  7. django文件上传、图片验证码、抽屉数据库设计

    1.Django文件上传之Form方式 settings.py, ALLOWED_HOSTS = ['*'] INSTALLED_APPS = [ 'django.contrib.admin', 'd ...

  8. 【志银】NYOJ《题目529》flip

    题目:flip 题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=529 吐槽Time: 由于此题槽点太多,所以没忍住... 看到这题通过率出 ...

  9. NodeJs01 文件浏览器

    ES6常用新语法 前言 是时候学点新的JS了! 为了在学习NodeJs之前,能及时用上语言的新特性,我们打算从一开始先学习一下JavaScript语言的最基本最常用新语法.本课程的内容,是已经假设你有 ...

  10. ExtJs学习之MessAgeBox的使用

    1.Ext.MessageBox.alert() 调用格式: alert( String title, String msg, [Function fn], [Object scope] ) 参数说明 ...