First create the name myfuns
# My script functionsfunctionAddem {Echo$[ $1+ $2 ]}functionMultem {Echo$[ $1* $3 ]}functionDivem {if[ $2-ne0 ] Then Echo$[ $1/ $2 ] Else Echo-1 fi}
Then create a script with the name: test14. SH
#!/bin/bash# using functions definedinchA libraryfile./myfunsvalue1=Ten; value2=5RESULT1=' Addem $value 1 $value 2 ' result2=' Multem $value 1 $value 2 ' RESULT3=' Divem $value 1 $value 2 'Echo "The result of adding them is: $result 1"Echo "The result of multiplying th is: $result 2"Echo "The result of dividing them is: $result 3"
where ./myfuns is called to use a different path depending on the path, and the two files in this article are in the same directory
Run sh test14. SH
Output:
test14. SH 7 : Addem:command not foundtest14. SH 8 : Multem:command not foundtest14. SH 9
I haven't found the mistake yet.
Shell Script Create Library