I have some lines in a file like:This is one word1:word2 of the lines    This is another word3:word4 of the lines    Line without a match    Yet another line word5:word6 for testI need to grep for : and to return words just before and after :.Output I need from greping above lines isword1:word2word3:word4word5:word6
grep words around a token
grep
With GNU grep:start cmd:> echo This is one word1:word2 of the lines |  grep -Eo '[[:alnum:]]+:[[:alnum:]]+'word1:word2start cmd:> echo This is one wordx:wordy of the lines |  grep -Eo '[[:alpha:]]*:[[:alpha:]]*'wordx:wordystart cmd:> echo This is one wo_rdx:wo_rdy of the lines |  grep -Eo '[[:alpha:]_]*:[[:alpha:]_]*'wo_rdx:wo_rdy