hpfinder (linux 文件内容查找 )
来源:互联网 发布:葫芦线切割3b编程实例 编辑:程序博客网 时间:2024/06/05 09:05
可实现在不同目录下的递归查找文件内容
源码:
#!/bin/shif [ -n "$2" ];thenpath=$2elsepath=`pwd`ficd $pathfor i in `ls`do log=$path/$iif [ -d "$log" ];thencd $logfor j in `ls`doif [ -f "$j" ];thenrs=`cat $j|grep $1`if [ -n "$rs" ];thenecho ==== in `pwd`/$j =====cat $j|grep $1echo ==== end =====echofielsenpath=`pwd`hpfinder $1 $npath fidoneelsers=`cat $log|grep $1`if [ -n "$rs" ];thenecho ==== in $log =====cat $log|grep $1echo ==== end =====echofifidone
./hpfinder 查找的内容 [查找目录]
[root@EM-FGXTT2X test]# pwd/tmp/test[root@EM-FGXTT2X test]# tree ..|-- a|-- b|-- c`-- dir2 |-- a |-- b `-- c1 directory, 6 files
在目录/tmp/test 下的文件a b c,和子目录dir2下的a b c 内容下
[root@EM-FGXTT2X test]# cat a b cone line1two line2one line1two line2aaaaaaaaabbbbbbbbbline3
执行
hpfinder line
结果:
[root@EM-FGXTT2X test]# hpfinder line ==== in /tmp/test/a =====one line1two line2==== end ========= in /tmp/test/b =====one line1two line2==== end ========= in /tmp/test/c =====line3==== end ========= in /tmp/test/dir2/a =====one line1two line2==== end ========= in /tmp/test/dir2/b =====one line1two line2==== end ========= in /tmp/test/dir2/c =====line3==== end =====
详情见:https://github.com/HappyAaron/hpfinder
0 0
- hpfinder (linux 文件内容查找 )
- linux 查找文件内容
- linux查找文件内容
- linux 查找文件内容
- Linux查找文件内容
- Linux查找文件内容
- Linux查找文件内容
- Linux查找文件内容(grep)
- Linux查找文件内容(grep)
- Linux查找文件内容(grep)
- Linux批量查找文件内容
- linux 查找文件内容命令
- linux下查找文件内容!
- linux下查找文件内容
- linux按内容查找文件
- linux查找文件内容grep
- linux按内容查找文件
- linux按内容查找文件
- RSA机密算法原理
- xcode获取更多崩溃调试信息
- OpenWrt 编译流程详解
- webservice开发
- 面向对象
- hpfinder (linux 文件内容查找 )
- iOS/object-c: 枚举类型 enum,NS_ENUM,NS_OPTIONS
- Android虚线View
- 第五章作业
- CSU1619: Con + tin / (ued + Frac / tions)
- HDU 4461 The Power of Xiangqi
- 【经典算法】——KMP,深入讲解next数组的求解
- 第七章作业
- [error C2228: “.begin”的左边必须有类/结构/联合]之我见