do
echo $i
done
如果a b c d为字符串变量且含有空格,建议放在双引号中,写为 "$a" "$b" "$c" "$d"
[seesea@UC ~]$ cat a.txt1
2
3
4
a
b
c
d
[seesea@UC ~]$ ar=( $(cat a.txt) )
[seesea@UC ~]$ for (( i = 0i <${#ar[@]}++i ))do echo "ar[$i] = ${ar[i]}"done
ar[0] = 1
ar[1] = 2
ar[2] = 3
ar[3] = 4
ar[4] = a
ar[5] = b
ar[6] = c
ar[7] = d
用数组更方便吧。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)