先创建名称为 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. 【Pro ASP.NET MVC 3 Framework】.学习笔记.7.SportsStore:购物车

    3 创建购物车 每个商品旁边都要显示Add to cart按钮.点击按钮后,会显示客户已经选中的商品的摘要,包括总金额.在购物车里,用户可以点击继续购物按钮返回product目录.也可以点击Check ...

  2. linux,shell输入反斜杠显示'W'。

    linux,shell输入反斜杠显示'W'. solution: 字体必须为"Courier New".

  3. 用Meta标签控制360浏览器默认极速模式打开自己的网站和正则表达式

    在head标签中添加一行代码: <html><head><meta name="renderer" content="webkit|ie-c ...

  4. Spring和MyBatis环境整合

    SSH框架的结合几乎家喻户晓,但是一般的中小项目,使用Spring和MyBatis就够了,而且MyBatis轻便好使,易上手,值得大家尝试一次. 开篇简介: Spring: Spring是一个轻量级的 ...

  5. mount/umount系统调用

    转载自:http://blog.sina.com.cn/s/blog_6385c7310100iqmn.html 功能描述: mount挂上文件系统,umount执行相反的操作.    用法:   # ...

  6. JavaScript脚本语言基础(三)

    导读: 数学对象(Math) 数组对象(Array) 字符串对象(String) 日期对象(Date) js对象是属性和方法的集合.JavaScript中的所有事物都是对象,如:字符串.数值.数组.函 ...

  7. JAVA中int、String的类型相互转换

    int -> String int i=12345;String s="";第一种方法:s=i+"";第二种方法:s=String.valueOf(i); ...

  8. exp函数

    第一种是tensor用exp函数 th> a [torch.DoubleTensor of size 1x3] [.0002s] th> a:exp() 2.7183 2.7183 1.0 ...

  9. 2016 Al-Baath University Training Camp Contest-1 C

    Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...

  10. Http 请求

    public static string HttpGet(string url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Creat ...