What does a | (pipe character) do in a shell (bash) command?

I have to run this command to install NPM. What does it do? What is the | at the end?

curl | bash

Also, am I running UNIX-like commands in Bash? Why does this work? Is it that Bash is a UNIX-command compatible interface for the terminal?


  • In Bash (and most *nix shells), the | (pipe) metacharacter¹ causes the shell to take the output from one command and uses it as the input for the next command.

    What you are doing here is using curl to retrieve the file and then output its contents into bash, which is a shell that will execute the contents of

    In short, you are downloading and running the script.

    1. A shell metacharacter is a character/symbol with a special meaning to the shell and it causes termination of a word unless it is quoted. For example, |, >, <, etc are shell metacharacters.