Can I call a function of a shell script from another shell script?

問題:

I have 2 shell scripts.我有 2 個 shell 腳本。

The second shell script contains following functions second.sh第二個 shell 腳本包含以下函數second.sh

func1 
func2

The first.sh will call the second shell script with some parameters and will call func1 and func2 with some other parameters specific to that function. first.sh 將使用一些參數調用第二個 shell 腳本,並使用特定於該函數的一些其他參數調用 func1 和 func2。

Here is the example of what I am talking about這是我正在談論的示例

second.sh第二個.sh

val1=`echo $1`
val2=`echo $2`

function func1 {

fun=`echo $1`
book=`echo $2`

}

function func2 {

fun2=`echo $1`
book2=`echo $2`


}

first.sh第一個.sh

second.sh cricket football

func1 love horror
func2 ball mystery

How can I achieve it?我怎樣才能實現它?


解決方案:

參考: https://stackoom.com/en/question/jPV8
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章