Super User is a question and answer site for computer enthusiasts and power users. 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 want to search in many many files for a string.

I used find /archive/* -print0 | xargs -0 grep 'robert' -sl

Is there a simple method to do it ?

share|improve this question

migrated from May 12 '11 at 11:38

This question came from our site for professional and enthusiast programmers.

The shell expands *. Just omit it, and find will figure out what to do.

find /archive -print0 | xargs -0 grep 'robert' -sl
share|improve this answer
wooow :D:D thx it works – Roby May 12 '11 at 8:55
+1 have a read up on how "globs" work. It's really useful to know. – James C May 12 '11 at 8:56

There is no need for find. Just use.

grep -m 1 -rsl 'robert' archive/
share|improve this answer
ok, is there any way say, if zou found 100 files its ok and print them out and stop searching more ? – Roby May 12 '11 at 9:22
@Roby grep -rsl 'robert' archive/ | head -100 – Timofey Stolbov May 12 '11 at 9:28
@Timofey: is grep then stopping ? because i had really large files.... like 2mio. – Roby May 12 '11 at 9:30
@Roby Yes of course. – Timofey Stolbov May 12 '11 at 9:35
@Roby: grep -rslm 100 'robert' archive/ – grawity May 12 '11 at 14:16

Your Answer


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