1
0

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.

UNIX/ShellScript

Last updated at Posted at 2018-02-23

配列を使用する
参考URL:http://shellscript.sunone.me/array.html

$ array=(111 "foo" 222 "bar" 333 "foobar")
#↑配列に値を設定する。

$ echo $array
111
#↑インデックスを指定しない場合は、先頭の値のみが出力される。

$ echo ${array[@]}
111 foo 222 bar 333 foobar
#↑全ての値を出力する場合は、インデックスに「@」を指定する。

for文
変数は${}で囲む

# team_cのすべての要素でteam_cにマッチした行をteam_nameに格納
for team_name in ${team_c[@]};do 
  echo ${team_name} >> 'unix_result_2.txt'

# grep -c マッチした行数を表示
# 変数名は${}で囲む
  grep -c ${team_name} ${league_csv} >> 'unix_result_2.txt'
  done  # for文の終わり

echo >> 'unix_result_2.txt'
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?