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

Grep has been acting strangely on one of my systems (Ubuntu Desktop - all my other systems are Ubuntu Server), and I can't figure out why. I created a control file named text that contains the following text:


the following commands work on all of my systems except the problem child:

$ grep grep *
$ grep 'test!!' *

On my problem child grep simply hangs. I have compared .bashrc, .bash_aliases, and even /etc/bash_completion, but I can't find the problem. Any ideas what could be causing the problem?

share|improve this question
Does it work if you pass in the path name of the control file rather than * ? – SiegeX Feb 8 '11 at 4:30
It might also help if you could post the output of an strace. strace grep grep * – Patrick Feb 8 '11 at 4:35
Did you try grepping after copying the test file from one of the machine where you did not have this problem? By the way how was the file created? maybe it may have something to do with utf ?!? – yasouser Feb 8 '11 at 5:25
what does "type grep" say? – chris Feb 8 '11 at 8:52
SiegeX: It does work, and it also works if I use 'tex*' – JohnB Feb 8 '11 at 18:04
up vote 6 down vote accepted

On the problem machine, in the directory you grep 'something' * are there any special files like sockets, named pipes (fifos), etc. there ?

At least in the case of a named pipe, grep won't get an EOF from the named pipe until something actually writes an EOF to the named pipe.

share|improve this answer
Thanks for your input - if Patrick doesn't post an answer, you'll get the credit. – JohnB Feb 8 '11 at 18:18
How would you do a grep -r and exclude named pipes? I've run into this problem too where grep hangs when it gets to a named pipe... – Tyler Rick Mar 12 '12 at 18:51
I figured it out: Use 'grep --devices=skip -r ...' – Tyler Rick Mar 12 '12 at 18:55

If it hangs, it sounds to me like it is looking for input from stdin.

You can prove that by typing Control-D (once only) - it will return to the shell.

If this is correct then * does not find any files.

share|improve this answer
<Ctrl>-D does not do anything - I need to use <Ctrl>-C to kill grep. I agree though - it sounds like it is looking for input from stdin. – JohnB Feb 8 '11 at 17:59

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.