There’s a hint to the problem in the error message; there’s an extra space showing:
bash: wc: …
Rather than:
bash: wc: …
I assume from your question you’re using a Mac. I’m going to guess that you're using a keyboard layout in which typing the |
character requires using the Alt/Option key. I think that what might be happening is that you are letting your finger linger on the Alt key as you type the space.
Alt+Space types a non-breaking space rather than a regular space character, which Bash’s parser does not consider to be whitespace of any sort and therefore takes as part of the command name.
It works the second time because you’re typing more carefully!