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 tried using Cygwin to emulate some cool Linux search feature, and when I do grep in files (12 text files - not big) it takes forever. I used

grep -rne word

I could find this word faster manually (even without Ctrl + F). Is there any reason this does not work? How to fix it?

P.S.: I use the Cygwin console.

share|improve this question
Try grep -rne word * This * should not be necessary, but it work for me – user108263 Dec 5 '11 at 16:55
up vote 3 down vote accepted

You forgot to tell grep where to search, so it just sits there waiting for data to be input from 'stdin' – often a pipe, but in this case your keyboard. You can confirm by entering something like "this is a word", Enter, CtrlZ, Enter.

If you want to search the current directory, recursively, give . as the path.

grep -rne word .

(Note 2012-07: The latest version of GNU grep will search the current directory automatically if -r is given.)

In many cases, * will work too, but it is not recommended because 1) it is inefficient – expanding the wildcard to all file names takes some time and might even overflow the permitted command line length; 2) it does not match dotfiles (names starting with a dot) in most shells, although I'm not sure if this applies to expansion done by Cygwin itself.

share|improve this answer
Expansion of wildcards is handled by the shell, and Cygwin uses bash by default. It works the same way as on Linux or Unix systems. – Keith Thompson Dec 5 '11 at 19:26
Be careful. grep -rne word . > grep.out will include grep.out in the files being searched, and will run until you run out of disk space. – Keith Thompson Dec 5 '11 at 19:28
@Keith: Cygwin programs can be run from cmd.exe and PowerShell as well, in which case the expansion has to be done by the program itself (or by the Cygwin runtime). – grawity Dec 5 '11 at 19:56
@grawity Yep, the Cygwin DLL does that if a Cygwin program is invoked from outside Cygwin. – ak2 Dec 5 '11 at 20:20

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.