8、在Shell脚本中使用函数
来源:互联网 发布:数据脱敏规则 编辑:程序博客网 时间:2024/06/05 14:59
8、在Shell脚本中使用函数
学习目标
Shell的函数
Shell程序也支持函数。函数能完成一特定的功能,可以重复调用这个函数。
函数格式如下:
函数名(){ 函数体}
函数调用方式:
函数名 参数列表
实例:编写一函数add求两个数的和,这两个数用位置参数传入,最后输出结果。
root@ubuntu:/home/study# vi test3
#!/bin/bash add(){ a=$1; b=$2; z=`expr $a + $b`; echo "The sum is $z";}add $1 $2
root@ubuntu:/home/study# chmod +x test3
root@ubuntu:/home/study# ./test3 1 2
0 0
- 8、在Shell脚本中使用函数
- shell脚本中函数的使用
- Linux中shell脚本使用函数
- 在shell脚本中使用ftp telnet
- 在shell脚本中使用sudo
- 在shell脚本中使用alias
- 在Shell脚本中使用窗口
- shell脚本:函数使用
- 使用FUNCNAME 和BASH_LINENO实现shell脚本中定位函数错误在代码中的位置
- Linux命令行与shell脚本(13)--在函数中使用普通变量
- Linux命令行与shell脚本(14)--在函数中使用数组
- shell .bashrc中函数在其他脚本无法调用问题
- 在Lua脚本中使用OpenGL函数
- 在PB中使用JavaScript脚本函数
- 在Lua脚本中使用OpenGL函数
- shell脚本的函数使用
- 在Android.mk编译脚本中使用shell bash命令
- 在shell脚本中,如何写使用for循环
- 数百个 HTML5 例子学习 HT 图形组件 – 3D 建模篇
- Struts2的零配置插件convention的简单总结
- PHP编程效率的20个要点
- extern "c"用法解析
- eclipse中添加多个tomcat服务器!
- 8、在Shell脚本中使用函数
- 将元转换成万元 java jstl
- Java中的super限定
- Server Name Indication翻译(多证书TLS扩展)
- 收录文章
- Linux查看CPU和内存使用情况
- 9、在Shell脚本中调用其他脚本
- c++中 try catch throw的基本用法【by徐玉丽】
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)