LoginSignup
42

More than 5 years have passed since last update.

Bashで連想配列を使用する

Last updated at Posted at 2014-02-26
declare -A hash_

で定義して

hash_["a"]="test"

のように使う

中身を参照するときは

echo ${hash_["a"]}

とする。

echo ${hash_}

とはできない。

キーの一覧の取得

echo ${!hash_[@]}

参考URL: http://stackoverflow.com/questions/3112687/how-to-iterate-over-associative-array-in-bash

TODO: 連想配列を他の変数に代入する方法を調べる。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42