shell编程中使用函数库
来源:互联网 发布:飞客数据 编辑:程序博客网 时间:2024/06/07 16:56
在shell中使用函数库可以在多个脚本中使用相同的库函数,就相当于高级语言中的文件包含。
那么创建函数库的形式是:如函数库:myFuncs
#my Funcs,the is function librirayfunction First(){echo "First Functions"}function Second(){echo "Second Function"}function Three(){echo "Three Function"}function Four(){echo "Four Function"ls -l $HOME}
创建好以后使用命令source命令来编译;在shell中,对于source命令有一个快捷方式,使用点操作,使用它只是进行编译,在当前shell环境下允许,而不是创建新的shell来执行,使用创建的自定义库以后,在testso shell脚本中使用如:
#!/bin/bash#library test. ./myFuncs #the is connect libraryecho "lib test Begin...."First #This is called the contents inside librarySecond<span style="white-space:pre"></span> #This is called the contents inside libraryThree<span style="white-space:pre"></span> #This is called the contents inside libraryFour #This is called the contents inside libraryfunction name(){echo "name"}输出结果是:
[soft01@localhost ~]$ ./testso lib test Begin....First FunctionsSecond FunctionThree FunctionFour Function总计 36drwxr-xr-x 2 soft01 soft01 4096 08-30 18:31 Desktop-rwxrwxrwx 1 soft01 soft01 201 08-30 18:51 myFuncs-rw-rw-rw- 1 soft01 soft01 199 08-30 18:51 myFuncs~-rwxrwxrwx 1 soft01 soft01 469 08-30 18:15 test-rw-rw-rw- 1 soft01 soft01 471 08-30 18:03 test~-rwxrwxrwx 1 soft01 soft01 123 08-30 18:51 testso-rw-rw-rw- 1 soft01 soft01 123 08-30 18:49 testso~-rw-rw-r-- 1 soft01 soft01 258 08-30 18:15 wen-rw-rw-r-- 1 soft01 soft01 17 08-30 15:53 zhou
这样就完成了shell自定义函数库的使用。
- shell编程中使用函数库
- shell函数库使用
- shell编程中使用数组
- linux下编程使用math.h函数库
- shell编程中如何计算使用除法
- shell 编程中空格的使用
- shell 编程中各种括号的使用
- shell 编程中空格的使用
- shell 编程中空格的使用
- shell编程中条件表达式的使用
- keil中使用c的函数库
- C语言中使用mysql函数库
- 在VC中使用MATLAB C++函数库
- Shell Curses 函数库
- linux应用编程笔记(4)静态函数库和动态函数库使用
- Shell编程(一)---为什么使用Shell编程
- shell编程中xargs
- shell 编程中空格的使用–< 转>
- java内存机制
- DCI 设计实例
- CXF wsdl2Java
- 网络验证CRC校验
- 利用BlueJ对程序进行测试
- shell编程中使用函数库
- oracle 中em配置
- 精妙SQL语句,基础,提升,技巧
- JFace Dialog 样式设置
- win7 oracle11gR2Client PL/SQL安装之后不显示服务名
- 欧拉回路
- (java 基础知识) Java 安全套接字--javax.net.ssl
- Hadoop 新 MapReduce 框架 Yarn 详解
- linux驱动学习总结(一)——对linux驱动的几点思考