我有以下bash腳本將輸入文件拆分爲以下簽名的兩個文件: splitfiles文件名0.9 其中0.9是訓練集比例,其餘爲testset。使用bash將行分成火車和驗證集
function splitfiles()
{
length=$(wc -l $1)
top=$(($length*$2))
head -n $top $1 >traintxt
tail -n $(($length-$top)) $1 >valtxt
}
但它拋出下面的錯誤文件110-1.txt
$ splitfiles 110-1.txt 0.9
慶典:4756073 110-1.txt * 0.9:表達式語法錯誤(錯誤標記是 「110-1.txt * 0.9」)
這是怎麼得到的功能叫? – anubhava
splitfiles 110-1.txt 0.9 @anubhava – stackit
BASH算術不做浮點。 – anubhava