Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file with this type of lines:

blabla bla:bla whatever what:ever
alpha bravo charlie

I only want to keep the words that contain a colon.

So the output for the above would be:

bla:bla what:ever


Does anyone have any ideas?

share|improve this question

closed as off topic by MDMarra, Massimo, mdpc, Chris S Nov 8 '12 at 20:02

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

grep -oE '\w+\:\w+' filename.txt

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.