当前位置:网站首页>Shell custom function
Shell custom function
2022-07-01 23:51:00 【Resound through heaven】
1 grammar
# Definition of function
[ function ] funname ()
{
command
[return Return value ]
}
# Call function
funname Pass parameters 1 Pass parameters 2 ...
2 demo
#!/bin/bash
fun1()
{
echo " Call parameterless function "
}
fun2()
{
echo " Find the sum of two numbers ..."
read -p " Enter the first number : " n1
read -p " Enter the second number : " n2
return $(($n1+$n2))
}
fun3()
{
echo " The first parameter is zero :${1}"
echo " The second parameter is :${2}"
return $(($1+$2))
}
# Call parameterless function
fun1
# Call return function
fun2
rs=`echo $?`
echo " The sum of two numbers is : ${rs}"
# Call the third function
fun3 2 2
rs=`echo $?`
echo "fun3 The return result is : ${rs}"
边栏推荐
- Openwrt enable kV roaming
- Use vb Net to convert PNG pictures into icon type icon files
- 关联性——组内相关系数
- Current situation and future development trend of Internet of things
- Redis AOF日志
- Algolia's search needs are almost closed
- ADO.NET之sqlCommand对象
- 【QT】测试Qt是否能连接上数据库
- Development trend and future direction of neural network Internet of things
- The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem
猜你喜欢

Current situation and future development trend of Internet of things

多表操作-一对一,一对多与多对多

【QT】测试Qt是否能连接上数据库

Redis RDB快照

Notblank and notempty

Material design component - use bottomsheet to show extended content (I)
![[must] bm41 output the right view of the binary tree [medium +]](/img/a5/00b2f0df5ab448665a2b062d145e52.png)
[must] bm41 output the right view of the binary tree [medium +]

Postgresql源码(57)HOT更新为什么性能差距那么大?

Redis 主从同步
![[QT] qtcreator uninstall and installation (abnormal state)](/img/66/1b96326d87bca2a790a6694f38e79e.png)
[QT] qtcreator uninstall and installation (abnormal state)
随机推荐
Key points of security agreement
ADO.NET之SqlDataAdpter对象
【QT】對於Qt MSVC 2017無法編譯的問題解决
【无标题】
Key points and difficulties of the course "information content security" at Harbin Institute of Technology
小程序表单校验封装
Applet form verification encapsulation
SecurityUtils.getSubject().getPrincipal()为null的问题怎么解决
Material Design组件 - 使用BottomSheet展现扩展内容(一)
ARP报文头部格式和请求流程
Material design component - use bottomsheet to show extended content (I)
使用VB.net将PNG图片转成icon类型图标文件
安全协议重点
【必会】BM41 输出二叉树的右视图【中等+】
The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem
2021 RoboCom 世界机器人开发者大赛-高职组复赛
ADO.NET 之sqlConnection 对象使用摘要
Multi table operation - one to one, one to many and many to many
BlocProvider为什么感觉和Provider很相似?
Concurrentskiplistmap -- principle of table skipping