Skip to main content
1 of 3
user avatar
user avatar

grep certain number of words after match

How can I grep key word and the next four words. For example lest's say we have this paragraph:

Meta Stack Exchange is where users like you discuss bugs, features, and 
support issues that affect the software powering all 167 Stack Exchange 
communities.

I wan to grep the key word "Exchange " and the next four words so the output is "Exchange is where users like"

I used :

grep -Eo "Exchange" 

What I must add to this command to control the number of greps (words, numbers, charters ,...) after a key word

user88036