检查,如果grep命令的返回正确的输出 [英] checking if grep command returns correct output
本文介绍了检查,如果grep命令的返回正确的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的事情是,我使用的wget
来提取网址后,我想管它grep来检查,如果它的一些模式匹配,如果它仅仅回声名网址。
事情是这样的:
wget的网址| grep的模式
如果成功
显示URLNAME
解决方案
这是如果
条件为真,如果它的命令返回0 的grep
,如果它的模式来匹配输入返回0。
如果wget的-O - ... | grep的-q ...
然后
...
科幻
Thing is that I am using wget
to extract url after that I want to pipe it to grep to check if it matches some pattern and if it does simply echo name of url.
Something like this:
wget url |grep "pattern"
if successful
display urlname
解决方案
An if
condition is true if its command returns 0. grep
returns 0 if it matches the pattern to the input.
if wget -O - ... | grep -q ...
then
...
fi
这篇关于检查,如果grep命令的返回正确的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文