我需要在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
等等。
我该怎么做?我无法在输出内获得单引号符号('')。
+1
使用双引号,而不是单一的。内部单引号变量不扩展 –