当前位置:网站首页>Shell script (V) -- function
Shell script (V) -- function
2022-06-22 19:26:00 【Be the best Messi】
Catalog
One 、shell Function definition
3、 ... and 、 Function return value
5、 ... and 、 The scope of function variable
7、 ... and 、 Create function libraries
One 、shell Function definition
Write command sequences together in format , It is convenient to reuse the command sequence
Two 、 Format
1、 Format 1 :
function Function name {
Command sequence
}
2、 Format two :
Function name () {
Command sequence
}
3、 ... and 、 Function return value
return Represents the exit function and returns an exit value , You can use $ ? The variable displays the value
Usage principle :
- 1、 Take the return value as soon as the function ends , because $? Variable returns only the exit status code of the last command executed
- 2、 Exit status code must be 0~255, When exceeded, the value will be divided by 256 Remainder



Four 、 Function arguments


5、 ... and 、 The scope of function variable
- Function in Shell In the script, only in the current Shell Effective in the environment
- Shell Variables in scripts are globally valid by default
- Restrict variables to functions and use local command


6、 ... and 、 recursive
1、 Factorial


2、 Recursive directory lookup


7、 ... and 、 Create function libraries
Put commonly used functions into a separate library script , Facilitate the use of scripts , You can directly call the functions in this library


Catalog
One 、shell Function definition
3、 ... and 、 Function return value
5、 ... and 、 The scope of function variable
7、 ... and 、 Create function libraries
边栏推荐
- Niuke network: minimum coverage substring
- Mise en œuvre de redis par golang (10): transactions atomiques locales
- 一款支持HomeKit的摄像头?智汀 IPC摄像头IC1开箱体验
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- Error in created hook: “TypeError: Cannot read property ‘tableId‘ of undefined“
- Error in created hook: “TypeError: Cannot read property ‘tableId‘ of undefined“
- Vs Code suddenly fails to jump
- Service实战:使用Service完成一个下载任务
- JSP connection MySQL total error
- c# sqlsugar,hisql,freesql orm框架全方位性能测试对比之sqlserver
猜你喜欢

IPLOOK作为O-RAN联盟会员,将共同促进5G产业发展

In the first half of the year, there were 7 new unicorns in this field, and the capital scrambled to enter the market

第八届 GopherChina 大会蓄势待发!

Iplook becomes RedHat (red hat) business partner

一款支持HomeKit的摄像头?智汀 IPC摄像头IC1开箱体验

2022重庆幼教产业展览会|高科技玩具益智解压玩具博览会

牛客网:合并区间
Notes on Combinatorics (V) chains in distributive lattice
![jniLibs. Srcdirs = ['LIBS'] what's the use?](/img/d5/3070f8e793507efc601bb22d5024fa.png)
jniLibs. Srcdirs = ['LIBS'] what's the use?

IPLOOK 5GC与亚信国际CHF(计费功能)对接成功
随机推荐
Golang implements redis (10): local atomic transactions
Golang 實現 Redis(10): 本地原子性事務
到底使用Thread还是Service?
Complete the sqlsession interface and implementation classes
wpa_supplicant的状态机迁移
chrome突然无法复制粘贴了
Several important viewpoints on operation and maintenance, monitoring and aiops
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
集群、分布式、微服务概念和区别
Chrome suddenly can't copy and paste
std::enable_ shared_ from_ This error: error: expected template name before '<' token
China's two meteorological "new stars" data products are shared with global users
Which securities company is better to open an account when making an appointment to play new bonds? It is safer to open an account
牛客网:最小覆盖子串
数商云:数字化供应链系统搭建,赋能企业实现物流供应链的优化升级
有效的括号
程序员工具大全【持续更新】
mysql数据库设计
STM32控制矩阵按键,HAL库,cubeMX配置
IPLOOK和思博伦通信建立长期合作