使い方
参考:
Bash のパラメータのブレース展開での拡張子/ディレクトリ名/ファイル名の取得/拡張子の置換 | それマグで!
Bash でパラメータ展開を用いて変数を利用する | 俺的備忘録
Bash の変数パラメータ展開のまとめ | harry’s memorandum
Bash の変数パラメータ展開はやっぱし便利 | harry’s memorandum
How To Use Bash Parameter Substitution Like A Pro | nixCraft
Variables and Expansions | The Bash Guide
Bash variables and command substitution | Computational Methods in the Civic Sphere
An introduction to parameter expansion in Bash | Opensource.com
Parameter Substitution – Advanced Bash-Scripting Guide | The Linux Documentation Project
代入
hoge=$fuga hoge=`echo "hello"` hoge=$( echo "hello" )
参考:
シェルスクリプト (sh / bash / zsh) で変数から変数へ代入する方法について – Qiita
文字列を置換する
${var/pattern/replace}
:最初にマッチした文字列を置換${var//pattern/replace}
:全ての文字列を置換
参考:
間接変数展開 (Indirect Variable Expansion)
$ fire="red!" $ color="fire" $ echo "${!color}" red!
参考:
Bash expand variable in a variable – Stack Overflow
How to use a variable as part of an array name – Unix & Linux Stack Exchange
How do I assign a variable in Bash whose name is expanded from another variable? – Ask Ubuntu
JSON の構築
参考:
Bash で JSON に変数を埋め込むための3つの方法 | DevelopersIO
Tips/まとめ
参考:
部分文字列/置換/長さ/連結/分割の文字列処理 | バイオインフォ道場