bash字符串匹配
#!/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字符串匹配的更多相关文章
- leetcode笔记 动态规划在字符串匹配中的应用
目录 leetcode笔记 动态规划在字符串匹配中的应用 0 参考文献 1. [10. Regular Expression Matching] 1.1 题目 1.2 思路 && 解题 ...
- 字符串匹配的KMP算法
~~~摘录 来源:阮一峰~~~ 字符串匹配是计算机的基本任务之一. 举例来说,有一个字符串”BBC ABCDAB ABCDABCDABDE”,我想知道,里面是否包含另一个字符串”ABCDABD”? 许 ...
- {Reship}{KMP字符串匹配}
关于KMP字符串匹配的介绍和归纳,作者的思路非常清晰,推荐看一下 http://blog.csdn.net/v_july_v/article/details/7041827
- 字符串匹配(hash算法)
hash函数对大家来说不陌生吧 ? 而这次我们就用hash函数来实现字符串匹配. 首先我们会想一下二进制数. 对于任意一个二进制数,我们将它化为10进制的数的方法如下(以二进制数1101101为例): ...
- 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith
[C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...
- sdut 2125串结构练习--字符串匹配【两种KMP算法】
串结构练习——字符串匹配 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目链接:http://acm.sdut.edu.cn/sduto ...
- C语言字符串匹配函数
C语言字符串匹配函数,保存有需要时可以用: #include <stdio.h> #include <stdlib.h> #include <string.h> # ...
- 字符串匹配--Karp-Rabin算法
主要特征 1.使用hash函数 2.预处理阶段时间复杂度O(m),常量空间 3.查找阶段时间复杂度O(mn) 4.期望运行时间:O(n+m) 本文地址:http://www.cnblogs.com/a ...
- 字符串匹配的KMP算法详解及C#实现
字符串匹配是计算机的基本任务之一. 举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD" ...
随机推荐
- shell脚本默认变量值
脚本参数相关: $# 是传给脚本的参数个数 $ 是脚本本身的名字 $ 是传递给该shell脚本的第一个参数 $ 是传递给该shell脚本的第二个参数 $@ 是传给脚本的所有参数的列表 $* 是以一个单 ...
- 通过vSphere API获取对象Statistics
预备知识点: 1.vim.PerformanceManager.MetricId() 通过counter_id获取到metric_id 2.vim.PerformanceManager.Quer ...
- Linux上网设置
ifconfig 命令查看网络设置 步骤1.配置/etc/sysconfig/network-scripts/ifcfg-eth0 里的文件.有的是(ifcfg-ens33) 文件 CentOS下的i ...
- 算法(Algorithms)第4版 练习 1.3.41
方法实现: //1.3.41 public Queue(Queue<Item> q) { Queue<Item> result = new Queue<Item>( ...
- Jquery的load()
我一直认为jquery的load函数是以GET方式请求另一个文件并加载到当前DOM里的.当我带参数加载一个ASP脚本时是这样做: $("#showData").load(" ...
- jQuery对象和DOM对象的相互转化实现代码
jQuery对象和DOM对象相互转化 jQuery对象和DOM对象 jQuery对象就是通过jQuery包装DOM对象后产生的对象.jQuery对象是jQuery独有的,其可以使用jQuery里的方法 ...
- Hibernate学习---第八节:继承关系的映射配置
1.单表继承 (1).实体类,代码如下: package learn.hibernate.bean; import java.util.Date; /** * 持久化类设计 * 注意: * 持久化类通 ...
- [转]JS内存泄漏排查方法(Chrome Profiles)
Google Chrome浏览器提供了非常强大的JS调试工具,Heap Profiling便是其中一个.Heap Profiling可以记录当前的堆内存(heap)快照,并生成对象的描述文件,该描述文 ...
- angular-cli.json配置参数解析,常用命令解析
1.angular-cli.json配置参数解析 { "project": { "name": "ng-admin", //项目名称 &qu ...
- ansible 基础 简介及 安装
ansible 运维自动化工具. 没有客户端,底层通信依赖于系统软件,linux下基于openssh,win基于powershell