grep: command not found This is a very weird behavior. Lately, whenever I am trying to find a process on console with ps aux | grep foo, it is returning a grep: command not found. Ok, that could be something that I changed and did wrong, but the problem is that, after a few tries, it suddenly knows what grep is:

MM:.dev$ ps aux | grep foo
-bash:  grep: command not found
MM:.dev$ ps aux | grep foo
-bash:  grep: command not found
MM:.dev$ ps aux | grep foo
-bash:  grep: command not found
MM:.dev$ ps aux | grep foo
MM            70953   0,0  0,0  2699108    744   ??  Ss   10:32AM   0:08.77 foo bar
MM             3756   0,0  0,0  2423356    204 s004  R+   10:12AM   0:00.00 grep foo


Any ideas why is this happening?

As suggested, this is what I get when a enter type grep after both, the one failing and the one working:

MM:.dev$ ps aux | grep foo
-bash:  grep: command not found
MM:.dev$ type grep
grep is /usr/bin/grep
MM:.dev$ ps aux | grep foo
MM             5694   0,0  0,0  2433796    676 s006  S+   10:47AM   0:00.00 grep foo
MM:.dev$ type grep
grep is /usr/bin/grep
Looking at your output, there seems to be an extra space before grep in the error message. I assume this is coming from a still pressed Opt/Alt key after typing the pipe symbol (so you basically are typing Opt-Space instead of just Space). Try ps aux |grep foo (without a space between the pipe and the g).