Solving “bash: grep: command not found” on OS X
$ some script | grep something bash: grep: command not found
If you are using a Mac with a German keyboard layout and your typing is as sloppy as mine, chances are you are familiar with this error. You probably also know that deleting the space before grep fixes it. Why is this?
Option 7 corresponds to the | character. Option Space corresponds to the non breaking space which looks just like the regular space but is - as far as the shell is concerned - totally different. And obviously there’s no ‘ grep’ command on your system. And if you still hold down Option while pressing space… Guess what will happen… Now how do we fix it?
Check out the documentation on Mac OS X Key Bindings or simply make your ~/Library/KeyBindings/DefaultKeyBinding.dict file look like this (if it doesn’t exist create it, if there are already bindings in it just add the one from below)
{
"~ " = ("insertText:", " ");
}
What does this do? Every time you press Option Space instead of inserting a non breaking space OS X now inserts a regular space. Problem fixed.