35

I've seen that rvm (ruby version manager) is installed using the following command:

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

So as I understand we get the script content and pass it to the bash (I believe < < and << is the same thing?) I am interested in the < < part, found following description on the net:

<< token Means use the current input stream as STDIN for the program until token is seen.

This is somehow not clear for me, can someone make an example or explain it in more simple way?

0

2 Answers 2

44

No, < < and << are not the same thing.

The first is composed of the common < redirection character combined with the first character of the <(command) syntax. This is a ksh construct (also found in bash and zsh) known as process substitution that takes the output of command and provides it in a file whose name refers to the other end of the pipe command is writing to.

In other word you can think of < <(command) as < file, where file contains the output of command.

4
  • 5
    I learnt about this command a few days ago, it's a very useful command. The things which you can do with this are only limited by your imagination: e.g. this command gives you a list of only hidden files : diff <(ls) <(ls -a) Oct 18, 2011 at 3:06
  • 2
    This syntax might indeed be quite useful but in Stonerain's specific case, it doesn't seem to provide any added value compared to a simple pipe.
    – jlliagre
    Nov 27, 2011 at 9:57
  • 1
    In the above syntax it doesn't help. But if you change it slightly, it's much better: bash <(curl ...) instead of bash < <(curl ...) doesn't steal STDIN, so you're free to answer prompts and provide input in the script.
    – tylerl
    Dec 21, 2011 at 19:23
  • Using <() seems to be a great alternative for sending multiple $variables to commands directly, instead of having to needlessly write the $variables to files first. diff <(echo "$text1") <(echo "$text2") stackoverflow.com/questions/13437104/…
    – Sepero
    Dec 6, 2012 at 16:52
19

It is a convoluted way of doing the simpler:

curl -s https://raw.github.com/... | bash
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.