当前位置:网站首页>shell函数
shell函数
2022-08-05 05:10:00 【1701y】
目录
shell函数
将命令序列按格式写在一起
可方便重复使用命令序列
shell函数定义
function 函数名 {
命令序列
}
函数名 () {
命令序列
}
shell函数调用
1 直接写 函数中调用函数 直接写函数名
2 同名函数,后一个生效
3 调用函数一定要先定义
4 只要先定义了调用的,其他函数定义顺序无关
declare -F ##查看当前系统的所有函数
declare -f 查看当前系统的所有函数的定义规则
写一个判断操作系统的函数
函数返回值
return表示退出函数并返回一个退出值,脚本中可以用$?变量显示该值
使用原则:
函数一结束就取返回值,因为$?变量只返回执行的最后一条命令的退出状态码
退出状态必须是0~255,超出时值将为除以256取余
函数传参
函数的变量的作用范围
由此看出函数内部定义变量会影响外部变量的使用
函数递归
阶乘
边栏推荐
- 8.04 Day35-----MVC three-tier architecture
- The difference between span tag and p
- Requests the library deployment and common function
- uboot enable debug printing information
- 【微信小程序】WXML模板语法-条件渲染
- Shell(4)条件控制语句
- Flutter学习4-基本UI组件
- Talk about 20 common problems in data governance
- 【cesium】元素高亮显示
- u-boot in u-boot, dm-pre-reloc
猜你喜欢
随机推荐
span标签和p标签的区别
结构光三维重建(二)线结构光三维重建
flex布局青蛙游戏通关攻略
入口点注入
Feature preprocessing
App快速开发建设心得:小程序+自定义插件的重要性
C#关于set()和get()方法的理解及使用
dedecms报错The each() function is deprecated
LAB Semaphore Implementation Details
Flutter真机运行及模拟器运行
开发一套高容错分布式系统
Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer
u-boot debugging and positioning means
【学生毕业设计】基于web学生信息管理系统网站的设计与实现(13个页面)
说说数据治理中常见的20个问题
dedecms error The each() function is deprecated
How to deal with DNS hijacking?
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
『递归』递归概念与典型实例
ansible各个模块详解