3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bashで配列の数だけfor文を回す

Posted at

bashで変数の要素数の分だけfor文を回したい時があったのでメモ。

$ export a=("kawakamasu1" "kawakamasu2" "kawakamasu3" "kawakamasu4" "kawakamas
u5")
# 要素番号部分に"@"をつける
$ for i in ${a[@]};do echo $i;done
kawakamasu1
kawakamasu2
kawakamasu3
kawakamasu4
kawakamasu5
3
3
0

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?