Skip to main content
deleted 1 character in body
Source Link
user88036
user88036

How can I grep key word and the next four words. For example lest'slet'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

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

How can I grep key word and the next four words. For example let'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

edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
Source Link
user88036
user88036

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