2014-09-29 72 views
0

下面的命令中「$」符號的含義是什麼? ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"有人可以解釋下面的homebrew安裝命令嗎?

+0

下載並執行ruby中該鏈接上的代碼 – aelor 2014-09-29 07:32:48

+0

ruby​​評估curl命令的輸出 – 2014-09-29 07:51:33

回答

2

這是一個叫做command substitution的shell特徵。 $(command)替換爲命令的輸出:

$ echo puts 1 + 2 
puts 1 + 2 

$ ruby -e "$(echo puts 1 + 2)" 
3 

第二行相當於ruby -e "puts 1 + 2"

在您的示例中,curl命令下載並輸出Ruby fileruby -e對其進行評估。

相關問題