Friday, November 6, 2009

How to grep next word after a match?

This example of regex will search for a given word and then pick the next word also as output

# echo "This example will pick next word as well" | /usr/sfw/bin/ggrep -o -E -- "next \w+"
next word


Note: This example is good for Solaris system. For any other system, may be a GNU grep will produce same output!!!

No comments: