Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐: 强烈推荐:Ylmf OS 3.0 正式版发布附迅雷高 XP系统下硬盘安装Fedora 14图文教程
搜索:
您的位置: Linux安全网 > Linux入门 > » 正文

declare的功能

来源: 未知 分享至:

declare
-i 将参数定义为整数数字
e.g
[root@monitor test]# cat ceshi.sh
#!/bin/bash
sum=1+1
declare -i sum=1+1
echo "$sum"
[root@monitor test]# ./ceshi.sh
2

-x 将变量设置为环境变量
[root@monitor test]# a=test
[root@monitor test]# declare -x a
[root@monitor test]# set |grep a=test
a=test

-a 定义数组

-r 将变量定制为只读
e.g
[root@monitor test]# a=abc
[root@monitor test]# echo $a
abc
[root@monitor test]# a=123
[root@monitor test]# echo $a
123
[root@monitor test]# declare -r a
[root@monitor test]# echo $a    
123
[root@monitor test]# a=abc
-bash: a: readonly variable


Tags: declare 整数 数字 定义 参数
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史