(需要Word版笔记的请私信留邮箱)
【IBM小型机AIX操作系统总结16–AIX常用shell脚本】
脚本运行
假设脚本:/mnt/test.sh
ksh /mnt/test.sh --指定shell运行文档,文档可无执行权限
chmod a+x /mnt/test.sh --给脚本增加执行权限
/mnt/test.sh --绝对路径运行脚本
以上两种方式:都是新开一个shell来运行脚本,运行完毕后,shell关闭
所以在脚本中环境变量的设置不生效。
source /mnt/test.sh --source表示,在当前shell下运行脚本,不开新shell
. /mnt/test.sh --点"."的功能和source功能一样
语法
read ming --请求从键盘输入数据赋值给变量,ming是变量
ming=`lsuser -a ALL` --当命令结果为多行数据时 ,赋值给变量,不换行存储
echo $ming
read ming < /mnt/f1 --读取文档中的第一行文字,赋值给变量
运算:
expr 和
let 求和
bc 计算器
大于,等于,小于
shell范例1:如下
shu=1
while read hang --组