xgqfrms / bash-all-in-one

linux bash
https://bash-all-in-one.xgqfrms.xyz
MIT License
1 stars 0 forks source link

bash script advanced #3

Open xgqfrms opened 2 years ago

xgqfrms commented 2 years ago

bash script advanced

bash function

https://www.runoob.com/linux/linux-shell-func.html

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions#%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0_vs_%E5%87%BD%E6%95%B0%E5%A3%B0%E6%98%8E_vs_%E5%87%BD%E6%95%B0%E8%A1%A8%E8%BE%BE%E5%BC%8F

image

xgqfrms commented 2 years ago

bash function 定义

  1. function test () {}
#!/usr/bin/env bash

# function 定义
function test () {
  echo "test function with keyword and ()"
}
test
  1. function test {}
#!/usr/bin/env bash

# function 声明式
function test {
  echo "test function with keyword"
}
test
  1. test () {}
#!/usr/bin/env bash

# 命令式 ()
test (){
  echo "test function with ()"
}
test

image

xgqfrms commented 2 years ago

bash function define

bash 函数定义