如何使用sed / grep来提取两个单词之间的文本? [英] How to use sed/grep to extract text between two words?
本文介绍了如何使用sed / grep来提取两个单词之间的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ b
输入:
输入: pre $
这是一个字符串
输出:
是
使用:
sed -n'/ Here /,/ String / p'
code>
包含端点,但我不想包含它们。
解决方案
sed -e's / Here \(。* \)String / \ 1 /'
I am trying to output a string that contains everything between two words of a string:
input:
"Here is a String"
output:
"is a"
Using:
sed -n '/Here/,/String/p'
includes the endpoints, but I don't want to include them.
解决方案
sed -e 's/Here\(.*\)String/\1/'
这篇关于如何使用sed / grep来提取两个单词之间的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文