当前位置:网站首页>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取余

函数传参


函数的变量的作用范围


由此看出函数内部定义变量会影响外部变量的使用


函数递归
阶乘


边栏推荐
- 人性的弱点
- dedecms后台生成提示读取频道信息失败的解决方法
- dedecms报错The each() function is deprecated
- In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
- 淘宝账号如何快速提升到更高等级
- Day019 方法重写与相关类的介绍
- u-boot调试定位手段
- 密码学系列之:PEM和PKCS7,PKCS8,PKCS12
- 【cesium】3D Tileset 模型加载并与模型树关联
- University Physics---Particle Kinematics
猜你喜欢

类的底层机制

Flutter learning three-Flutter basic structure and principle

JeeSite New Report

The underlying mechanism of the class

Dephi reverse tool Dede exports function name MAP and imports it into IDA
![[cesium] 3D Tileset model is loaded and associated with the model tree](/img/03/50b7394f33118c9ca1fbf31b737b1a.png)
[cesium] 3D Tileset model is loaded and associated with the model tree

Application status of digital twin technology in power system

Dephi逆向工具Dede导出函数名MAP导入到IDA中

Flutter学习三-Flutter基本结构和原理

Machine Learning Overview
随机推荐
8.04 Day35-----MVC three-tier architecture
write the story about us
[Student Graduation Project] Design and Implementation of the Website Based on the Web Student Information Management System (13 pages)
Flutter learning 5-integration-packaging-publish
C#关于set()和get()方法的理解及使用
入口点注入
Feature preprocessing
Cron(Crontab)--use/tutorial/example
Flutter TapGestureRecognizer 如何工作
After controlling the export file in MySQL, it becomes \N. Is there any solution?
Qt produces 18 frames of Cupid to express his love, is it your Cupid!!!
u-boot debugging and positioning means
Shell(4) Conditional Control Statement
Flutter real machine running and simulator running
Detailed explanation of Mysql's undo log
大学物理---质点运动学
MySQL Foundation (1) - Basic Cognition and Operation
How can Flutter parent and child components receive click events
The log causes these pits in the thread block, you have to guard against
for..in和for..of的区别