Find characters that have 2 or more *

Viewed 40

If I want to show the lines that have 2 or more times the character this *.

egrep '*{2}' file 
1 Answers

You may use

grep '\*[^*]*\*' file 

The \*[^*]*\* pattern will match a line that has *, then any 0+ chars other than * and then a *.

See online demo:

s="*one
*two*
.... *three* and more text here**"
grep '\*[^*]*\*' <<< "$s"

Output:

*two*
.... *three* and more text here**
Related