Apple - grep: command not found

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).


My answer may sound strange, but I had this effect with an old keyboard as well when I typed too fast. Just try typing it again, move with your cursor before the letter "g" of grep, delete the whitespace that could have been entered with a still pressed ALT/Option key, hit the space key again and fire up your commandline.

Another workaround is to lower the keyboard repeat rate in System Preferences, if you are not typing with ten fingers. :-)