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 likeI used :grep -Eo Exchange What I must add to this command to control the number of greps (words, numbers, charters ,...) after a key word
grep certain number of words after match
text processing;grep
Using sequences of space and non-space characters maybe?$ grep -Eo 'Exchange([[:space:]]+[^[:space:]]+){4}' << EOFMeta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 167 Stack Exchange communities.EOFExchange is where users likeor (perl-style, if your grep supports it)$ grep -Eo 'Exchange(\s+\S+){4}' << EOFMeta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 167 Stack Exchange communities.EOFExchange is where users likeNote that grep does not match across lines - for multi-line matches, you can use pcregrep instead.