0
節省定界符變量時使用$(建造,然後在bash創建here文檔的換行符被改爲美元符號$。特殊性在慶典
[email protected]:/shared/git2/etl/appminer$ IRB=$(cat -e<<'HERE'
> require 'irb/ext/save-history'
> IRB.conf[:SAVE_HISTORY] = 100
> IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
> HERE
>)
[email protected]:/shared/git2/etl/appminer$ echo $IRB
require 'irb/ext/save-history'$ IRB.conf[:SAVE_HISTORY] = 100$ IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"$
要打印的變量中的雙引號不轉換到換行符但仍保留了美元符號:
[email protected]:/shared/git2/etl/appminer$ echo "$IRB"
require 'irb/ext/save-history'$
IRB.conf[:SAVE_HISTORY] = 100$
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"$
注:這是一個後續約在bash定界符變量的SOF問題:以下How to assign a heredoc value to a variable in Bash?