Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After a pipe the command is considered prefixed with a space

Sometimes on my terminal (Ubuntu) when I type:

ls | grep toto

I get this error:

 grep: command not found*

Notice that the shell is writing grep prefixed by a space. How can this be possible?

like image 852
user2854544 Avatar asked Nov 15 '13 11:11

user2854544


1 Answers

<Checks the source of your original question>

<pre style="width:650px; white-space:pre-wrap">Sometimes on my terminal (Ubuntu) when I type :

ls |&#160;grep toto

Thank you for copy-pasting the actual line! (But you didn't copy-paste the error message, naughty you!) See the problem? You have an unbreakable space after the pipe symbol. Shells only understand ASCII characters; all non-ASCII characters, including U+00A0 NO-BREAK SPACE, are treated as word constituents, so that unbreakable space is treated as part of the word that's in command name position.

You're presumably using a keyboard layout where you need to hold down AltGr to type |. Make sure to release the AltGr modifier so as not to accidentally type AltGr+Space instead of Space. Note that you don't need a space there, you can type ls |grep toto if that's easier on your fingers.

like image 74
Gilles 'SO- stop being evil' Avatar answered Nov 13 '22 00:11

Gilles 'SO- stop being evil'