Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

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

curl https://raw.githubusercontent.com/creationix/nvm/v0.23.2/install.sh | 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?

like image 586
Jwan622 Avatar asked Oct 30 '15 11:10

Jwan622


1 Answers

In bash (and most *nix shells) the | (pipe) symbol takes 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 install.sh file and then output its contents into bash, which is a shell that will execute the contents of install.sh

In short, you are downloading and running the install.sh script.

like image 106
Chris Tompkinson Avatar answered Sep 18 '22 04:09

Chris Tompkinson