bash < <(curl -s https://rvm.io/install/rvm): What Does it Do? [duplicate] bash < <(curl -s https://rvm.io/install/rvm): What Does it Do? [duplicate] bash bash

bash < <(curl -s https://rvm.io/install/rvm): What Does it Do? [duplicate]


The first < redirects the file on the right side to the stdin of the command on the left side.

The <(...) syntax runs the command specified, saving its output to a named pipe (a special kind of file that outputs whatever is written into it without saving it to the disk) and replaces the whole <(...) with the name of the file. This is called process substitution (you can look it up in man bash) and it is used whenever a file would be needed but you want to use the output of a command instead.

As for curl, it is a command which downloads the URL given to it as argument, and outputs it to the screen (stdout).

In summary, what the command you gave does is:

  1. Runs bash, giving it as input the contents of a temporary named pipe.
  2. Downloads the URL https://rvm.io/install/rvm, which is a bash script, and saves it to the temporary named pipe given as input to bash.

This effectively runs the script at the URL with bash.


The <(command) syntax is used to perform process substitution. Read more about it here: http://tldp.org/LDP/abs/html/process-sub.html

It is very useful when you want the output of one command to be fed as file argument to another command. The <(command) syntax makes the output behave as if it were a file.

For example, we know that perl requires a perl program as its argument.

Now, if the perl program resides in a URL say, http://pastebin.com/raw.php?i=wdtZYvvr, we know the output of curl http://pastebin.com/raw.php?i=wdtZYvvr would be the program in that URL. So, we can supply the output of this command as an argument to perl as follows:

perl <(curl http://pastebin.com/raw.php?i=wdtZYvvr)

I often find process substitution very useful when I want to take the diff of outputs from two commands rather than two files. But diff requires two file arguments. So, we supply the two outputs as files to diff using process substitution.


Many shells, including bash, use the < to redirect input. foo<<(bar) means foo will read output of bar as input.