How to define a bash function for use in any script?

来源:互联网 发布:淘宝网平板电脑大全 编辑:程序博客网 时间:2024/05/30 05:42


0down vote

Place your "common" function in a separate script (let's call it "a"):

#!/bin/bashtest_fun () {    echo "hi"}

Next, "import" it into another script (say, "b"):

#!/bin/bash. ./atest_fun

Running bash b will output "hi"

0down vote

Place your "common" function in a separate script (let's call it "a"):

#!/bin/bashtest_fun () {    echo "hi"}

Next, "import" it into another script (say, "b"):

#!/bin/bash. ./atest_fun

Running bash b will output "hi"

0 0
原创粉丝点击