设为首页 加入收藏

TOP

Linux下的shell与make(二)
2014-11-24 11:52:49 来源: 作者: 【 】 浏览:4
Tags:Linux shell make
数n,则等待进程n结束。


#cat waitdemo


echo “This is a new file”


(sleep 5; date)&


wait


echo “the file terminate”


执行结果:


This is a new file


April 20 10:08:26 BJT 2002-04-20


The file terminate


6) trap:中断处理命令


trap 命令表 中断信号表


#cat trapfile


trap echo ‘ This is INT 2’ 2


trap echo ‘ This is INT 3’ 3


for I in /bin /bin/usr


do


echo $I


done


下面程序实现scan:扫描当前目录下的每一个子目录,并执行用户提交的命令:


d=`pwd`


for i in *


do


if test –d $d/$i


then


cd $d/$i


while echo “$i:”


trap exit 2


read x


do trap : 2 ; eva l $x; done


fi


done


7)点命令 .


在bsh利用 . 命令执行一个命令时,不创建子进程。(csh中用source)


8)空命令:不做任何事情



下面程序dircmp测试当前目录与指定目录是否含有相同文件数


if test $# -ne 1 then


echo “Usage:dircmp dirname”



exit 1


else if test !-d $1 then


echo “\”$1\” is not a directory”



exit 1


else


this = `ls –l |grep ‘^-’ | wc –l `


that = `ls –l $1 |grep ‘^-’ | wc –l `


if test $this –ne $that then


echo “Current directory and \”$1\” do not match”



else


echo “Current directory and \”$1\” have same number of files”



fi


fi


fi


#dircmp abc


“abc” is not a directory


1) $chmod u+x dircmp


$./dircmp /usr/bin


2) $sh dircmp



3) $sh < dircmp


4) $ . dircmp(用点命令执行程序,不创建子进程)


%source dircmp(csh中)


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LED驱动程序 下一篇Android自定义地图示例:QQ地图

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·深入理解 Java 集合 (2025-12-27 07:22:48)
·Java集合框架全面解 (2025-12-27 07:22:45)
·时隔 15 年,巨著《J (2025-12-27 07:22:43)
·定义一个类模板并实 (2025-12-27 06:52:28)
·一文搞懂怎么用C语言 (2025-12-27 06:52:25)