分类: LINUX
2005-12-20 21:49:27
从文件读取到变量
status.file
内容
status: OK
filename :
xxxx.dat
yyyy.dat
zzzz.dat
aaaa.dat
非数组读取
n=0
while read line
do
export f$n="$line"
((n++))
done < status.file
echo "this is $f1"
echo "this is $f2"
echo "this is $f3"
echo "this is $f4"
echo "this is $f5"
echo "this is $f6"
要输出某个指定的变量 echo "$f$((n-1))"
读到数组中
如果你想存数组的话 试试这个
$n=0;while read line
>do
>string=`echo $line $string`
>((n++))
>done
$echo "${f[n-1]}"