Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 really don't look forward to having to do find/grep because the output, as returned by

find . -exec grep sometext {} \; -print

is just not very easy to read even when you dump it in a file. What I would like is if the file name had an indentation of 0 and then each file line where a match was found were indented with the line number and each match is highlighted in color.

Let me know if this is possible. I just can't read the awful output as it comes out of the command that I know.

I go between ksh and bash.

share|improve this question
up vote 4 down vote accepted

How about:

grep --color=auto -r -n sometext *

Example output:

filename:10:    foo sometext bar

The first field is the filename, second field is the line number and sometext is colored.

share|improve this answer

Or maybe

find . -exec grep -H {} \;
share|improve this answer
"This is the default when there is more than one file to search" - man grep. – jasonwryan Oct 9 '12 at 0:28
@jasonwryan his method only calls a single file at time, so there is only one file to search. Using + instead of \; would provide multiple files to grep, be more efficient, and is defined by POSIX. – jordanm Oct 9 '12 at 1:26
@jordanm Thanks: I hadn't grasped that. – jasonwryan Oct 9 '12 at 1: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.