您的位置:首页 > 运维架构 > Shell

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

2014-06-12 13:56 423 查看
0down
vote
Place your "common" function in a separate script (let's call it "a"):
#!/bin/bash

test_fun () {
echo "hi"
}


Next, "import" it into another script (say, "b"):
#!/bin/bash

. ./a

test_fun


Running
bash
b
will output "hi"

0down
vote
Place your "common" function in a separate script (let's call it "a"):
#!/bin/bash

test_fun () {
echo "hi"
}


Next, "import" it into another script (say, "b"):
#!/bin/bash

. ./a

test_fun


Running
bash
b
will output "hi"

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: