1

As stated in this question (and especially in John1024's answer, | is a metacharacter and hence, does not need spaces around it.

It makes me really confused because when I try to pipe a command I get an error "<cmd>: command not found". If I delete the space after the pipe symbol, the command runs perfectly. Even stranger: after successfully piping a command, I can run the same command with a space after the pipe symbol.


For instance :
  • man bash | grep foo will return -bash: grep: command not found
  • man bash |grep foo will output 3 lines containing 'foo'
  • man bash | grep foo will now run and output the 3 same lines

I'd be really grateful if anyone could explain this behavior

Sumak
  • 253
  • 1
  • 7

0 Answers0