在shell脚本中优化grep(或使用AWK)
发布时间:2020-12-15 22:16:46 所属栏目:安全 来源:网络整理
导读:在我的 shell脚本中,我试图使用$sourcefile中找到的术语一遍又一遍地搜索相同的$targetfile. 我的$sourcefile格式如下: pattern1pattern2etc... 我必须搜索的低效循环是: for line in $( $sourcefile);do fgrep $line $targetfile | fgrep "RID" $outputfi
在我的
shell脚本中,我试图使用$sourcefile中找到的术语一遍又一遍地搜索相同的$targetfile.
我的$sourcefile格式如下: pattern1 pattern2 etc... 我必须搜索的低效循环是: for line in $(< $sourcefile);do fgrep $line $targetfile | fgrep "RID" >> $outputfile done 我知道可以通过将整个$targetfile加载到内存中,或者使用AWK来改进这一点吗? 谢谢 解决方法
我错过了什么,或者为什么不只是fgrep -f“$sourcefile”“$targetfile”?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
热点阅读