1: 输出正确的文件名
cat gbz.txt |while read f ; do h=20130715/$f/*billing0715231[0-4]*; grep -l 'img4.cache.netease.com' $h 2>/dev/null ; done
跟据频道得到文件
nohup cat gbz.txt |while read f; do cd /Data/billing/history/20130809/$f; grep -l 'cc.test.ismartv.tv' *|while read h; do cp /Data/billing/history/20130809/$f/$h /Data/billing/history/20130809/gbz/; done; done &
2:去掉没用的 No such file or directory 报错
用grep命令的-s选项
cat gbz.txt |while read f;do grep -s 'img.500.com' 20131031/$f/*billing1031121[0-4]* |awk '{print $4}'; done
并求合:
cat gbz.txt |while read f;do grep -s 'img.500.com' 20131031/$f/*billing1031121[0-4]* |awk '{print $4}'; done |awk '{sum +=$1}END{print sum}'
3:判断grep是否有输出
判断tgz文件中是否存在该文件,存在就打出来
ls |while read f; do tar tzvf $f |grep 01066813O5_25515_live2_20131205060502704_21526.log && echo $f || echo > /dev/null ; done
原理:相当于三目运算符
expression && code(true) || code(false) #expression?code(true):code(true)
4:文件中有多个匹配行时每行都输出文件名
grep -H apple *
5:过滤不显示 -v
tail -f run.log |grep -v 'channel product billtype error'
6:显示过滤信息的前|后n行(-C 前后)
tail -f run.log |grep -A 3 'get channel list size'
tail -f run.log |grep -B 3 'get channel list size'
tail -f run.log |grep -B 3 'get channel list size'
7:过滤多个条件
grep -E 'a|b|c' a.txt #egrep 'a|b|c' a.txt
相关推荐
grep用法,grep用法,grep用法,grep用法,grep用法,grep用法,grep用法,
egrep是grep的扩展,支持更多的re元字符, fgrep就是 fixed grep或fast grep,它们把所有的字母都看作单词,也就是说,正则表达式中的元字符表示回其自身的字面意义,不再特殊。linux 使用GNU版本的grep。它功能更强...
linux下grep的详细用法介绍,有需要的欢迎下载
Grep是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。linux使用GNU版本的Grep。它功能更强,可以通过-G、-E、-F命令行选项来使用eGrep和fGrep的功能。Grep的工作方式是这样的,它在一...
grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。Unix的grep家族包括grep...
Indesign GREP 正则表达式用法及介绍
实验表明,基于GReP通用可重构处理器架构实现的模乘算法其运行效率比Intel CORETM i7平台上实现效率提高60%左右。实验充分说明了GReP通用可重构处理器在提高处理能力与执行效率方面有明显优势。
grep,find,grep和find连用的一些简单用法
__RCSID("$NetBSD: grep.c,v 1.11 2012/05/06 22:27:00 joerg Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #...
grep (缩写来自Globally search a Regular Expression and Print)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。Unix的grep家族包括grep、egrep和fgrep
grep "[5-8][6-9][0-3]" myfile 匹配myfile中第一位为5|6|7|8,第二位6|7|8|9,第三位为0|1|2|3的三个字符的行 ;grep "4\{2,4\}" myfile 匹配myfile中含有44,444或44444的行 grep "\?" myfile匹配myfile中含有...
grep源码关于grep的详细源码关于grep的详细源码关于grep的详细源码
linux grep 命令的详情解释 给初级者
在Linux系统下grep命令的功能非常的强大,其作用是查找整个文件里符合条件的关键字,grep命令在查找关键字时,只要查找到包含该关键字的行,就会把该行所有的内容全部显示出来。在使用grep命令时,如果配合管道符...
linux下的大名鼎鼎的grep命令的源代码
GrepConsole.zip
在处理庞大数据量时,善用Linux三剑客sed grep awk能省下不少劲。文档例子仅供参考学习!
win10 grep
Grep学习笔记.pdfGrep学习笔记.pdf