0

I try to grab words from a file:

$ grep -o '\*\*[^*]*\*\*' Principles_20_LifePrinciples.md | grep -v -e "Origin" -e "Etymology"
**circumstance**
**case**
**condition**
**Anxiety**
**anxiety**
**the state of feeling nervous or worried that sth bad is going to happen**
**a worry or fear about sth**
**a strong feeling of wanting to do sth or of wanting sth to happen**

The result I intend is to get only words:

**circumstance**
**case**
**condition**
**Anxiety**
**anxiety**

Refactored code with specified quantifier {,20}:

$ grep -E -o '\*\*[^*]{,20}\*\*' Principles_20_LifePrinciples.md

Unfortunately, it returns nothing.

How to solve such a problem?

2

Without seeing the full text of the file, wouldn't:

grep -o '\*\*[a-zA-Z]*\*\*' file

work?

1

The re_format(7) man page says, about the braces construct:

A bound is { followed by an unsigned decimal integer, possibly followed by , possibly followed by another unsigned decimal integer, always followed by }.

Notice that the first integer is not optional!

In other words, if you say {0,20} instead of {,20}, it should work (at least if "zero to twenty" is what you want!).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .