プロが教える店舗&オフィスのセキュリティ対策術

下記のシェルを作成しています。
count=1
cat ./tmp.csv |while read line
do
number[$count] = `echo $line |cut -f 1 -d ","`
count=`expr $count + 1`
done
rm ./tmp.csv

実行結果を確認するとエラーが出力され、変数に値が格納されません。
$ ./test.sh product_14647339.csv
./test.sh: 行 35: number[1]: コマンドが見つかりません
./test.sh: 行 35: number[2]: コマンドが見つかりません
./test.sh: 行 35: number[3]: コマンドが見つかりません
./test.sh: 行 35: number[4]: コマンドが見つかりません
./test.sh: 行 35: number[5]: コマンドが見つかりません

どのようにしたら配列変数に値が格納されますでしょうか。
よろしくお願いいたします。

質問者からの補足コメント

  • HAPPY

    number[$count] = `echo $line |cut -f 1 -d ","`の=部分にスペースがある事が原因でした。
    ありがとうございました。

      補足日時:2021/03/24 13:52

A 回答 (1件)

以下のコマンドを実行してからお答えします。



uname -a
echo $SHELL
$SHELL --version
    • good
    • 0
この回答へのお礼

ありがとうございます。
結果を下記に貼り付けます。

$ uname -a
CYGWIN_NT-10.0-WOW DESKTOP-84EFR2F 2.10.0(0.325/5/3) 2018-02-02 15:21 i686 Cygwin

$ echo $SHELL
/bin/bash

$ $SHELL --version
GNU bash, バージョン 4.4.12(3)-release (i686-pc-cygwin)
Copyright (C) 2016 Free Software Foundation, Inc.
ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

よろしくお願いいたします。

お礼日時:2021/03/24 12:53

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!