Chinaunix首页 | 论坛 | 博客
  • 博客访问: 537868
  • 博文数量: 119
  • 博客积分: 3167
  • 博客等级: 中校
  • 技术积分: 1215
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-20 21:21
文章分类

全部博文(119)

文章存档

2015年(21)

2012年(4)

2011年(1)

2007年(11)

2006年(50)

2005年(32)

分类: 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]}"


阅读(760) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~