Search code examples
bashosx-lionpipepiping

Bash piping in OSX prompts command not found, sometimes


In the OSX terminal :

du -h | sort -nr
-bash:  sort: command not found

which sort
/usr/bin/sort

The weird thing is: I tried reproducing the error and it seems to be totally random. My PATH echoed:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/texbin:/Users/sytycs/.rvm/bin

This only occurs when piping and happens with grep, more, less etc. Any idea what is causing this?


Solution

  • That space is not a space. Erase and replace it.