Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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'm using grep to do this, like:

grep someText file.log

But this returns the complete line in results. If someText is found in the middle of a line I don't want to ouput the whole line, just the part after and including the someText. Is there a way to achieve this?

share|improve this question
up vote 6 down vote accepted

Append a .* to your search and use the -o (--only-matching) option:

grep 'someText.*' -o file.log
share|improve this answer
Thanks a lot... – Daud Ahmad May 12 '11 at 6:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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