Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

bash: command not found after piping

Hi,


I'm trying something quite commonly found in an Unix environment, namely piping the output of one command into the input of a subsequent one, eg.


bash$ ps ax | grep -i bash


But unfortunately I'm receiving--and now comes the most curious part--most of the times (not always!!) an error message


bash: grep: command not found


When calling grep directly


bash$ grep


the resulting output is


Usage: grep [OPTION]... PATTERN [FILE]...

Try `grep --help' for more information.


"which"-ing the commands


bash$ which bash ps grep


results in


/bin/bash

/bin/ps

/usr/bin/grep



Cheers,

MMHein

Mac mini, Mac OS X (10.7)

Posted on Jan 29, 2012 1:15 AM

Reply
32 replies

Dec 1, 2016 9:52 AM in response to MMHein

Also having had this, i just researched and came to this http://stackoverflow.com/questions/8694442/bash-piping-in-osx-prompts-command-no t-found-sometimes


If you are not on an american keyboard, and like me have to do alt + 7 to get a pipe, it happens easily that the alt is still pressed when i hit the space. This results in a so called hard space, which only looks like a space, but is not recognized by the shell. Hence the error.


Try without a space after the pipe. (or make sure you let go of alt)

DO NOT reinstall your system

bash: command not found after piping

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.