如何到grep -o不-o [英] How to grep -o without the -o
本文介绍了如何到grep -o不-o的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经得到了1.01的BusyBox提供我的命令。因此,-o是不包括在grep的。我怎样才能获得的grep -o
无...行为-o?
I've got BusyBox v1.01 providing my commands. Hence, -o is not included in the grep. How can I get grep -o
behavior without the ... -o?
推荐答案
如果您有 SED
您可以使用简单的正则表达式。 (请参见 linuxquestions.org )
If you have sed
you can use simple regex. (see linuxquestions.org)
sed -n 's/.*\(PATTERN\).*/\1/p' FILE
因此,要找到只有在一个文件中的文本计算器
file.txt的
你写
sed -n 's/.*\(StackOverflow\).*/\1/p' file.txt
记住sed命令模式是一个普通的前pression。所以,如果你的模式包含常规的前pression任何元字符,它们需要进行转义。
Remember the pattern in the sed command is a regular expression. So If your pattern contains any meta characters of regular expression, they need to be escaped.
这篇关于如何到grep -o不-o的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文