<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[实践OK]Linux下用Grep -E参数实现$grep -E  ^[a-Z] supervisord.conf显示非注释项，ABC def abc，加上正则表达式实现，多个函数查找的方法，及实现查看所查找单词的前三行后两行的环绕搜索，grep一个多行单独IP间隔包含文字里的IP列表出来,grep查找时显示找到那行的后面N行-A，和前面N行参数-B的实际应用。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 28 Dec 2010 12:14:51 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	cat&nbsp;&nbsp;xxxx.txt&#124;grep -Ev &quot;无锡&#124;腾讯云&#124;华为云&#124;微软云&#124;阿里云&#124;百度云&#124;金山云&quot;&nbsp;&nbsp;#grep 正则接合v排除的查询<br/><br/>api-itv-xxxx-cn-master-php-db578496b-zxxnj&nbsp;&nbsp; 6/6&nbsp;&nbsp;&nbsp;&nbsp; Running&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;65m<br/>kubectl get po -l pro=itv_api&#124;grep -E &quot;Running +0&quot;&nbsp;&nbsp;&nbsp;&nbsp;#加号+：匹配1个或多个前面的字符，它和星号*的作用相似，但它不匹配0个字符的情况。比如，&quot;ab+c&quot;将匹配&quot;abc&quot;、“abbc”、“abbb...c”等。<br/><br/><br/>不用加正则参数也成，直接用egrep: <br/><textarea name="code" class="php" rows="15" cols="100">
rpm -qa &#124;egrep &#039;mysql&#124;java&#039; 
</textarea><br/>rpm -qf /bin/egrep<br/>grep-2.20-3.el6_7.1.x86_64<br/>rpm -ql grep-2.20-3.el6_7.1.x86_64&#124;grep grep<br/>/bin/egrep<br/>/bin/fgrep<br/>/bin/grep<br/><br/><br/>cat videoupload.php &#124;grep upload --color //给加点颜色。<br/><textarea name="code" class="php" rows="15" cols="100">
 rpm -qa&#124;grep -Erin &quot;ant&#124;ffmpeg&#124;mediainfo&#124;yamdi&#124;silkdecoder&#124;gpac&#124;atomicparsley&#124;mkvtoolnix&#124;logowise&#124;mplayer&quot;
89:ffmpeg-3.3.2-170713114010.el6.x86_64
92:yamdi-1.9-170713145824.el6.x86_64
106:mkvtoolnix-8.5.2-1.x86_64
108:mplayer-0.9.10-170719165738.el6.x86_64
280:mediainfo-0.7.97-2.1.x86_64
282:silkdecoder-3.0.0-170714111521.el6.x86_64
283:atomicparsley-0.9.4-170714113650.el6.x86_64
299:logowise-0.0.1-170718112806.el6.x86_64
488:ant-1.7.1-15.el6.x86_64
491:libmediainfo-0.7.97-1.1.x86_64
493:gpac-0.4.5-170714102354.el6.x86_64
</textarea><br/>背景:实现一次性查找多个函数的awk实现，以及grep一个文件里的所有IP行：<br/>-n ：grep 行输出，--line-number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print line number with output lines<br/>一）Grep -E参数，加上正则表达式实现，多个函数查找,如下:<br/><div class="code">grep -Erin &#039;atoi&#124;itoa&#124;atol&#124;ltoa&#124;intval&#039;&nbsp;&nbsp;./</div><br/>配上shell 文件 findfunPath.sh如下：<br/><div class="code">#!/bin/bash<br/>findPath=$1<br/>#judge folder is exist<br/>if &#91; ! -d &quot;$findPath&quot; &#93;; then<br/>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Sorry,Input path is not exist.&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;You can try follow command to check it: ls $&#123;findPath&#125;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;exit 0<br/>fi<br/>grep -Erin &#039;atoi&#124;itoa&#124;atol&#124;ltoa&#124;intval&#039;&nbsp;&nbsp;$&#123;findPath&#125;&#124;awk -F&quot;:&quot; &#039;&#123;print &quot;&#92;nFileLineNumber=&quot; $2 &quot;&nbsp;&nbsp;&nbsp;&nbsp; ExistFileName=&quot; $1 &quot;&#92;nDetailInfo<br/>=&quot; $0&#125;&#039;</div><br/>简单示例：<br/><div class="code">findfunPath.sh /usr/local/pro/</div><br/><br/><br/><br/>二）查看所查找单词的前三行后两行的环绕搜索：<br/><textarea name="code" class="C" rows="15" cols="100">
grep&nbsp;&nbsp;-rin -B 3 -A 2 &quot;pthread_create Failed&quot; ./multepoolser.c
</textarea><br/><br/>[root@iZ25dcp92ckZ multepoolserver]# grep&nbsp;&nbsp;-rin -B 3 -A 2 &quot;pthread_create Failed&quot; ./multepoolser.c<br/>569-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;threadNum[i]=i;//给数组赋值,传入线程编号值，后传入线程里。<br/>570-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//if(pthread_create(&amp;handleEpollRd[i],NULL,pthread_handle_message, (void *)&amp;i))&#123;<br/>571-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(pthread_create(&amp;handleEpollRd[i],NULL,pthread_handle_message, (void *)&amp;threadNum[i]))&#123;<br/>572:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(errOut,&quot;pthread_create Failed : %s - %m&#92;n&quot;,strerror(errno));<br/>573-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loger(errOut);<br/>574-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -1;<br/>--<br/>591-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeThreadNum[i]=i;//给数组赋值,传入线程编号值，后传入线程里。<br/>592-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//if(pthread_create(&amp;saveUpFilePart2Diskk[i],NULL,sync_additional_writing_worker, NULL ))&#123;<br/>593-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(pthread_create(&amp;saveUpFilePart2Diskk[i],NULL,sync_additional_writing_worker, (void *)&amp;writeThreadNum[i]))&#123;<br/>594:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(errOut,&quot;pthread_create Failed : %s - %m&#92;n&quot;,strerror(errno));<br/>595-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loger(errOut);<br/>596-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -1;<br/><br/>三）grep一个多行单独IP间隔包含文字里的IP列表出来：<br/><textarea name="code" class="php" rows="15" cols="100">
grep &#039;[0-9]&#92;&#123;1,3&#92;&#125;&#92;.[0-9]&#92;&#123;1,3&#92;&#125;&#92;.[0-9]&#92;&#123;1,3&#92;&#125;&#92;.[0-9]&#92;&#123;1,3&#92;&#125;&#039; INPUT_FILE
</textarea><br/><br/><br/>四）grep查找时显示找到那行的后面N行-A，和前面N行参数-B的实际应用之查找域名里的root有哪些路径：<br/>grep -Er &quot;common.jackxiang.com&#124;vote.jackxiang.com&#124;answer.jackxiang.com&#124;scratch.jackxiang.com&#124;api.itv.jackxiang.com&#124;common.itv.jackxiang.com&#124;api.itv.cctv.com&#124;common.itv.cctv.com&quot; ./&nbsp;&nbsp;-A 7&#124;grep root<br/>./answer.jackxiang.com.conf-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /data/www/api.jackxiang.com/;<br/>./api.itv.jackxiang.com.conf:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /data/www/api.itv.jackxiang.com/;<br/>./vote.jackxiang.com.conf-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /data/www/api.jackxiang.com/;<br/>./scratch.jackxiang.com.conf-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /data/www/api.jackxiang.com/;<br/>./common.jackxiang.com.conf-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /data/www/api.jackxiang.com/;
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]Linux下用Grep -E参数实现$grep -E  ^[a-Z] supervisord.conf显示非注释项，ABC def abc，加上正则表达式实现，多个函数查找的方法，及实现查看所查找单词的前三行后两行的环绕搜索，grep一个多行单独IP间隔包含文字里的IP列表出来,grep查找时显示找到那行的后面N行-A，和前面N行参数-B的实际应用。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>