配列および if ステートメントで CShell を使用することに慣れていないという if ステートメント エラーが発生します。
私が読んでいる私のファイルは
FGF 101001011000
そして私のコードは
#!/bin/csh
foreach year (1999 2000 2001)
foreach month (1 2 3 4 5)
echo "" > $year$month
if ($month == 1) then
set letter = F
else if ($month == 2) then
set letter = G
else if ($month == 3) then
set letter = H
else if ($month == 4) then
set letter = R
else if ($month == 5) then
set letter = D
else
print "Fail"
endif
@ year2 = $year % 100
awk '{split ($2,b,""); if (b["'$month'"] == 1) print $1"'$letter'""'$year2'"}' fileRead >> newFile
end
end
month の値は文字列または数値ですか? その値を 1 の値と直接比較できますか? 前に set と言いましたが、letter を使用するたびに set を含める必要がありますか? if ステートメントは CShell でどのように機能しますか? CShell の配列は Java のように機能しますか? 私はJavaで月1を行うことを知っていますが、私の調査から、配列は0ではなく1から始まることを読みました.これは本当ですか? そして、ifエラーが発生する理由を誰か教えてもらえますか?