#/bin/sh
INPUT_ETH="eth0,eth1,eth2,eth3"
i=0
for eth in $(echo $INPUT_ETH | tr "," "\n")
do
eth_$i=$eth
echo "$eth_$i"
i=`expr $i + 1`
if [ $eth_$i = $BLA_BLA]
then;
..............
fi
done
* SH split.sh * *串分割輸出不存儲到單獨的變量
split.sh:找不到
命令split.sh:eth_0 eth_1 :command not found
split.sh:eth_2:command not found
split.sh:eth_3:command not found
final output shold be .. in variable「eth_0」the string valu shold be「eth0」same as for eth_1 .... eth_2 etc..etc ...在此之後我想打一個循環在這個變量下eth_0,eth_1等
如果你正在使用bash,你可以這樣做:'在$ {// INPUT_ETH,/}',而不是使用'tr' ETH。 –
好@WilliamPursell n guyz *請不要建議數組* –