从文件读取到变量
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<status.file;f=(`echo $string`);string="" #最后清空string避免多次运行会出错
$echo "${f[n-1]}"
相关热门文章
给主人留下些什么吧!~~
评论热议