
《Shell》
斐然成章
这个作者很懒,什么都没留下…
展开
-
Shell脚本中调用另外一个脚本的方法
在Linux平台上开发,经常会在console(控制台)上执行另外一个脚本文件,经常用的方法有:./my.sh 或 source my.sh 或 . my.sh;这三种方法有什么不同呢?我们先来了解一下在一个shell脚本中如何调用另外一个shell脚本,其方法有 fork exec source。1、fork ( /directory/script.sh) :如果s转载 2014-03-23 16:33:42 · 30648 阅读 · 0 评论 -
shell中如何判断一个变量是否为空
shell编程中,对参数的其中原创 2014-07-14 14:16:38 · 50934 阅读 · 0 评论 -
shell之使用eval模拟一维数组保存进程pids,并调用wait等待所有进程执行完返回
以下脚本实现的功能是启动多个memtester进程测试DDR的稳定性,并在后台运行;由于sh Shell不支持数组类型的数据类型,导致在while循环中不能把“$i”当索引使用数组。在这种情况下,使用eval pid$i=$!来保存启动的进程ID(该命令执行结果为:pid1=ID1, pid2=ID2, ......); 所有的memtester进程启动后,调用uwait()函数,同样使用eval原创 2014-09-10 14:53:02 · 2275 阅读 · 0 评论 -
shell捕捉信号,重定向信号处理函数
#!/bin/shclean(){ killall process 2>/dev/null}trap clean 1#kill -1 $$RC=0while [ $RC -eq 0 ]do processRC=$?done原创 2014-09-10 14:16:38 · 2357 阅读 · 0 评论 -
获取全路径文件名的文件名/文件位置/文件的后缀名/文件的前缀
$ pfName=/home/sgs/test.txt# 获取全路径文件名$ echo $pfName/home/sgs/test.txt# 获取文件名$ echo ${pfName##*/}test.txt# 获取该文件的位置$ echo ${pfName%/*}/home/sgs# 获取文件的后缀名$ echo ${pfName##*原创 2014-07-14 10:17:52 · 4740 阅读 · 0 评论 -
shell实现功能大杂烩
shell-删除文件的最后一sed -i '$d' inputfile原创 2014-09-24 14:17:07 · 747 阅读 · 0 评论 -
Special Shell Variables
The Bourne shell has a number of special “automatic” variables that it maintains for informational purposes. These variables provide information such as the process ID of the shell, the exit status of转载 2015-09-22 15:47:20 · 718 阅读 · 0 评论