0
我需要在Linux for循環中的引號('')。Linux Bash循環引號('')
for循環是這樣的:
i=1
for factor in 5 10 15 20 25 30 40 50 75 100; do
./libFM -task r -train train.txt.libfm -test test.txt.libfm -dim '1,1,$factor' -method sgd -learn_rate 0.001 -init_stdev 0.1 -iter 1000 -out ((i++))_factor_SGD.txt
done
這讓下面的輸出(前2圈):
./libFM -task r -train train.txt.libfm -test test.txt.libfm -dim 1,1,$factor -method sgd -learn_rate 0.001 -init_stdev 0.1 -iter 1000 -out 1_factor_SGD.txt
./libFM -task r -train train.txt.libfm -test test.txt.libfm -dim 1,1,$factor -method sgd -learn_rate 0.001 -init_stdev 0.1 -iter 1000 -out 2_factor_SGD.txt
但我需要的輸出看起來像這樣(爲第一個2圈):
./libFM -task r -train train.txt.libfm -test test.txt.libfm -dim '1,1,5' -method sgd -learn_rate 0.001 -init_stdev 0.1 -iter 1000 -out 1_factor_SGD.txt
./libFM -task r -train train.txt.libfm -test test.txt.libfm -dim '1,1,10' -method sgd -learn_rate 0.001 -init_stdev 0.1 -iter 1000 -out 2_factor_SGD.txt
等等。
我該怎麼做?我無法在輸出內獲得單引號符號('')。
使用雙引號,而不是單一的。內部單引號變量不擴展 –