文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>bash中的变量 3

bash中的变量 3

时间:2005-12-20  来源:ruiqingzheng

从文件读取到变量

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

相关阅读 更多 +
排行榜 更多 +
贪吃蛇冲冲冲最新版

贪吃蛇冲冲冲最新版

冒险解谜 下载
声控忍者手机版

声控忍者手机版

冒险解谜 下载
同盟军

同盟军

飞行射击 下载