bash中的变量 3

来源:互联网 发布:软件项目验收意见书 编辑:程序博客网 时间:2024/05/06 09:15

从文件读取到变量

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]}"


阅读(444) | 评论(0) | 转发(0) |
0

上一篇:bash中的变量 2

下一篇:find使用 和 一个递归

相关热门文章
  • linux 常见服务端口
  • 什么是shell
  • linux socket的bug??
  • linux的线程是否受到了保护?...
  • 一个适用于windows和linux的抓...
  • 制作jffs2文件系统
  • make命令详解
  • nagios 进程突然增多一个...
  • 第七章 进程调度
  • ubuntu安装tftp服务器
给主人留下些什么吧!~~