0
我已經在存儲在所述一個bash腳本擊語法錯誤以與陣列
IFS=, read -r -a start_files <<< $(head -n 1 file.txt)
IFS=, read -r -a end_files <<< $(tail -n 1 file.txt)
我也兩個值從文件中讀取
micro=1000000
IFS=#
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read start_time end_time
do
start_time=$(bc <<< "scale=6; $start_time/$micro")
end_time=$(bc <<< "scale=6; $end_time/$micro")
...
done < $INPUT
IFS=$OLDIFS
的值所定義的下列陣列進行比較的值時數組和在start_time和end_time是紀元時間,我的意思是像值1361810326.840284000,1361862515.600478000,1361990369.166456000
在「...」行我想比較的值start_time和d end_time,以下列方式存儲在數組中的所有值:
for i in `seq 0 116`;
do
if [ $start_time -ge ${start_files[$i]} && $start_time -le ${end_files[$i]}]; then
startF=$i
fi
done
for j in `seq 0 116`;
do
if [ $end_time -ge ${start_files[$j]} && $end_time -le ${end_files[$j]}]; then
endF = $j
fi
done
但是,此代碼會產生語法錯誤。我究竟做錯了什麼?
參數的命令需要通過例如分離空間。 – 2014-10-28 17:08:57
如果您在問題中指出了您的語法錯誤,這將會很有幫助。 – 2014-10-28 17:09:26
您在測試'''結束'之前缺少一個空格。 – 2014-10-28 17:09:34