文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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]}"

相关阅读 更多 +
排行榜 更多 +
奥丘树海之下小米服手游下载

奥丘树海之下小米服手游下载

角色扮演 下载
网络天才国际服手游下载

网络天才国际服手游下载

休闲益智 下载
御剑红尘手游官方版下载

御剑红尘手游官方版下载

角色扮演 下载