如果我想显示包含 2 倍或更多倍这个 *
字符的行。
egrep '*{2}' file
最佳答案
您可以使用
grep '\*[^*]*\*' file
\*[^*]*\*
模式将匹配包含 *
的行,然后是除 *
之外的任何 0+ 个字符> 然后是 *
。
参见online demo :
s="*one
*two*
.... *three* and more text here**"
grep '\*[^*]*\*' <<< "$s"
输出:
*two*
.... *three* and more text here**
关于regex - 查找具有 2 个或更多 * 的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61724794/