Shell Script Create Library

Source: Internet
Author: User

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


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.