先创建名称为 myfuns

# my script functions

function addem {
echo $[ $ + $ ]
} function multem {
echo $[ $ * $ ]
} function divem {
if [ $ -ne ]
then
echo $[ $ / $ ]
else
echo -
fi
}

然后创建脚本,名称为: test14.sh

#!/bin/bash
# using functions defined in a library file
./myfuns value1=;
value2=
result1=`addem $value1 $value2`
result2=`multem $value1 $value2`
result3=`divem $value1 $value2`
echo "The result of adding them is: $result1"
echo "The result of multiplying th is: $result2"
echo "The result of dividing them is: $result3"

其中 ./myfuns 是调用该文件,具体使用时可能因路径不同而使用不同的路径,本文中两个文件放在同一目录下

运行  sh test14.sh

输出:

test14.sh: line : addem: command not found
test14.sh: line : multem: command not found
test14.sh: line : divem: command not found
The result of adding them is:
The result of multiplying th is:
The result of dividing them is:

暂时还没找到错误在哪。

shell script创建库的更多相关文章

  1. Shell编程—创建函数

    1基本的脚本函数 函数是一个脚本代码块,你可以为其命名并在代码中任何位置重用.要在脚本中使用该代码块时,只要使用所起的函数名就行了. 1.1创建函数 有两种格式可以用来在bash shell脚本中创建 ...

  2. CentOS Linux下一个tomcat起停,查看日志的shell script

    CentOS 的tomcat安装目录:/usr/local/tomcat vi MyTomcatUitl.sh          创建文件chmod u+x MyTomcatUtil.sh   赋执行 ...

  3. 第十三章、学习 Shell Scripts 简单的 shell script 练习

    简单的 shell script 练习 简单范例 对谈式脚本:变量内容由使用者决定 [root@www scripts]# vi sh02.sh #!/bin/bash # Program: # Us ...

  4. Linux08--Shell程序设计03 shell script

    第一个Shell脚本——HelloWorld [root@localhost ~]# vi sh01.sh #!/bin/bash #!表明使用哪种shell # this is my first s ...

  5. 菜鸟教程之学习Shell script笔记(下)

    菜鸟教程Shell script学习笔记(下) 以下内容是学习菜鸟教程之shell教程,所整理的笔记 菜鸟教程之shell教程:http://www.runoob.com/linux/linux-sh ...

  6. 自学Linux Shell16.3-函数递归+创建库

    点击返回 自学Linux命令行与Shell脚本之路 16.3-函数递归+创建库 1. 函数递归 递归调用函数是指函数调用自身进行求解. 通常,递归函数有基值,函数最终递推到达该值. 许多高级数学算法使 ...

  7. Shell脚本编程(一):初识shell script

    Shell简介 Shell是一个命令解释器,它是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核 ...

  8. 使用 GNU Libtool 创建库

    这篇文档向大家介绍 GNU Libtool 的用途及基本使用方法,同时描述如何结合 GNU Autoconf 和 Automake 来使用 Libtool. 3 评论: 吴 小虎, 程序员, 天用唯勤 ...

  9. Linux的shell script

    Linux的shell script //编辑shell: vi a.sh //子进程运行shell sh a.sh //主线程运行shell source a.sh 相关例子: #!/bin/bas ...

随机推荐

  1. wghd的git代码仓库分支管理说明【转】

    英文原文:http://www.nvie.com/posts/a-successful-git-branching-model/ 原文作者:Vincent Driessen 本文经Linux大棚博主总 ...

  2. 在keil 4中添加stc系列芯片的方法--【sky原创】

    在keil 4中添加stc系列芯片的方法: 1.从官网下载uv3.cdb的文件网址是:http://www.stcmcu.com/ 2.下载好后把uv3.cdb文件改成STC.cdb:3. 然后将[S ...

  3. Length of Last Word

    class Solution { public: int lengthOfLastWord(string s) { ; ; while(s[i]&&s[i]==' ') i++; // ...

  4. DOS下如何同时显示时区日期和时间

    DOS下如何同时显示时区日期和时间 Echo %Date:~0,4%-%Date:~5,2%-%Date:~8,2% %Time:~0,2%:%Time:~3,2% 不显示周几 Echo %Date: ...

  5. Android应用插件式开发解决方法

    转自:http://blog.csdn.net/arui319/article/details/8109650 一.现实需求描述 一般的,一个Android应用在开发到了一定阶段以后,功能模块将会越来 ...

  6. Codeforces 735C:Tennis Championship(数学+贪心)

    http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场, ...

  7. WPF:窗体置顶

    1.设置窗体TopMost属性 private DispatcherTimer timer; public Window1() { InitializeComponent(); Loaded += n ...

  8. ACM题目————数素数

    令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数 ...

  9. css杂记

    1,font-variant: 设置文本是否为小型的大写字母,值可以为normal,small-caps; 2,a:link: 未访问过的 a:visited: 访问过的 a:active: 活动的链 ...

  10. gets()和getchar()还有getch()的区别

    getch()和getchar()区别:1.getch(): 所在头文件:conio.h 函数用途:从控制台读取一个字符,但不显示在屏幕上例如: char ch;或int ch: getch();或c ...