shell以字符串形式执行函数

2021-05-19  本文已影响0人  一路向后

1.脚本实现

#!/bin/bash

function a() {
   echo "hello a"
}

function b() {
   echo "hello b"
}

funcs=(a b)

# 执行函数a和函数b
${funcs[0]}
${funcs[1]}

2.运行及其结果

$ ./example.sh
hello a
hello b
上一篇 下一篇

猜你喜欢

热点阅读