先创建名称为 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. 深入研究java.lang.Runtime类【转】

    转自:http://blog.csdn.net/lastsweetop/article/details/3961911 目录(?)[-] javalang 类 Runtime getRuntime e ...

  2. grads 用arcgis分析站点的网格

    第一步,用工具创建渔网(要素类) 第二步:将站点excel导入,生成点要素 站点excle,点击上面节点导出数据即可. 第三步,叠加在一起,找网格编号.

  3. ORACLE 日期函数

    ORACLE 日期函数 SYSDATE  当前的数据库系统时间 ADD_MONTHS(加减指定的月份) MONTHS_BETWEEN(取两个日期之间相隔的月数) LAST_DAY(取指定日期所在月的最 ...

  4. 多线程并发流程控制之dispatch_group 有关函数

    A B C D 4个并发下载任务,怎样在第一时间知道任务全部完成? dispatch_group 可以帮我们实现这样的控制. 上代码,看说明. dispatch_group_t group = dis ...

  5. HDU 5724:Chess(博弈 + 状压)

    http://acm.hdu.edu.cn/showproblem.php?pid=5724 Chess Problem Description   Alice and Bob are playing ...

  6. Tautology 分类: POJ 2015-06-28 18:40 10人阅读 评论(0) 收藏

    Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10428   Accepted: 3959 Descri ...

  7. 2016年12月9日 星期五 --出埃及记 Exodus 21:4

    2016年12月9日 星期五 --出埃及记 Exodus 21:4 If his master gives him a wife and she bears him sons or daughters ...

  8. Redis的WEB界面管理工具phpRedisAdmin

    下载地址:http://down.admin5.com/php/75024.html 官方网址:https://github.com/ErikDubbelboer/phpRedisAdmin

  9. JS结构图

  10. C语言中的指针数组

    C语言中的指针数组是什么,像 char *a[]={"ddd","dsidd","lll"}; 这里讲一下注意如果我们使用了a也就是首元素的 ...