#!/bin/sh

foo()
{
    local basedir=$1
    local all_entries=`ls -c`

    for entry in $all_entries
    do  
        if test -d $entry; then
            cd $entry&&foo ${basedir}/$entry;cd - >/dev/null
        else
            if [[
$entry =~ .+\.(cpp|cc|h|hpp) ]]; then #
看这里
                #echo $basedir/$entry
                source_files="$source_files $basedir/$entry"
            fi  
        fi  
    done
}

foo .
echo $source_files

An additional binary operator, =~,
is available, with the same precedence as == and !=.  When it is used, the string to the right of the operator is considered an extended regular expression and matched accordingly (as in  regex(3)).   The  return value  is  0 if the string matches the pattern,
and 1 otherwise.  If the regular expression is syntactically incorrect, the conditional expression's return value is 2.

emacs和posix-basic不支持()特性

find . -path ./task -prune -o -print | awk '/.cpp$|.h$/ { printf("%s ",$0); }'

语议:

if -path ./task; then

    -prune

else

    -print

fi

-o是or的意思

bash字符串匹配的更多相关文章

  1. leetcode笔记 动态规划在字符串匹配中的应用

    目录 leetcode笔记 动态规划在字符串匹配中的应用 0 参考文献 1. [10. Regular Expression Matching] 1.1 题目 1.2 思路 && 解题 ...

  2. 字符串匹配的KMP算法

    ~~~摘录 来源:阮一峰~~~ 字符串匹配是计算机的基本任务之一. 举例来说,有一个字符串”BBC ABCDAB ABCDABCDABDE”,我想知道,里面是否包含另一个字符串”ABCDABD”? 许 ...

  3. {Reship}{KMP字符串匹配}

    关于KMP字符串匹配的介绍和归纳,作者的思路非常清晰,推荐看一下 http://blog.csdn.net/v_july_v/article/details/7041827

  4. 字符串匹配(hash算法)

    hash函数对大家来说不陌生吧 ? 而这次我们就用hash函数来实现字符串匹配. 首先我们会想一下二进制数. 对于任意一个二进制数,我们将它化为10进制的数的方法如下(以二进制数1101101为例): ...

  5. 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith

    [C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...

  6. sdut 2125串结构练习--字符串匹配【两种KMP算法】

    串结构练习——字符串匹配 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sduto ...

  7. C语言字符串匹配函数

    C语言字符串匹配函数,保存有需要时可以用: #include <stdio.h> #include <stdlib.h> #include <string.h> # ...

  8. 字符串匹配--Karp-Rabin算法

    主要特征 1.使用hash函数 2.预处理阶段时间复杂度O(m),常量空间 3.查找阶段时间复杂度O(mn) 4.期望运行时间:O(n+m) 本文地址:http://www.cnblogs.com/a ...

  9. 字符串匹配的KMP算法详解及C#实现

    字符串匹配是计算机的基本任务之一. 举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD" ...

随机推荐

  1. fzu 1476 矩形个数

    注意点:精度 #include<iostream> using namespace std; typedef long long ll; int main() { int a,b; ll ...

  2. ibdata1文件非常大如何解决,ibdata单独存储

    启用独立表空间innodb_file_per_table(如果这个参数没有开启,mysql会将数据.索引.元数据都存入到ibdata中的) 数据表 表索引 MVCC(多版本并发控制)数据 回滚段 撤销 ...

  3. JFreeChart的使用示例

    示例一,饼图,简单示例: 导入jar,代码文件: 运行结果: 代码: import org.jfree.chart.ChartFactory;import org.jfree.chart.ChartF ...

  4. HDU 4267 A Simple Problem with Integers(2012年长春网络赛A 多颗线段树+单点查询)

    以前似乎做过类似的不过当时完全不会.现在看到就有点思路了,开始还有洋洋得意得觉得自己有不小的进步了,结果思路错了...改了很久后测试数据过了还果断爆空间... 给你一串数字A,然后是两种操作: &qu ...

  5. 1.angular js 学习网址

    双向数据绑定: http://html-js.com/article/1863

  6. Oracle 11g的7个服务详解

    成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为:1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝写入服务,VSS(Volume Shad ...

  7. GitHub基本使用

    什么是GitHub? GitHub是用于版本控制和协作的代码托管平台.它可以让您和其他人在任何地方一起工作 本教程教你如GitHub必需资源,如仓库,分支,提交和拉请求.您将创建自己的Hello Wo ...

  8. Eclipse_常用技巧_02_使用Eclipse进行源码分析

    1.分析java类和接口的继承关系 具体做法: 在代码区中选择需要的类和接口定义,然后右击,选择“Open Type Hiberarchy”,可以在“Hiberarchy View”中看到继承关系 快 ...

  9. codeforces 651B B. Beautiful Paintings

    B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...

  10. 设计模式 之 《观察者模式 (Observer)》

    #ifndef __OBSERVER_MODEL__ #define __OBSERVER_MODEL__ #include <string> #include <iostream& ...