Reputation: 817
I have a txt file from which I want to get only the expressions of the type 'USA_word*' where * is whatever ( I don't want the whole line, only the expressions )
I try the command
grep -oP ''USA_word*''
But I get a list :
USA_word
USA_word
USA_word
.....
without the part signified by the *.
Upvotes: 1
Views: 30
Reputation: 626758
You may use
grep -o 'USA_word[^[:blank:]]*'
The [^[:blank:]]*
part matches 0+ non-whitespace chars.
Besides, this does not use -P
PCRE option, and uses a pure BRE POSIX regex making it compatible with the majority of grep
implementations.
Upvotes: 1