Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1583755
  • 博文数量: 92
  • 博客积分: 2002
  • 博客等级: 大尉
  • 技术积分: 4717
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-01 17:09
文章分类

全部博文(92)

文章存档

2013年(1)

2012年(6)

2011年(85)

分类: LINUX

2011-11-22 21:21:50

Great question!! The major difference the two "kill" is that shell built-in version of kill accept job id as its argument, example:

[root@localhost ~]# $ sleep 100 &
[1] 25623
[root@localhost ~]# $ `which kill` %1
kill: can't find process "%1"
[root@localhost ~]# $ kill %1
[root@localhost ~]# $
[1]+  Terminated              sleep 100


[root@localhost ~]# $ type kill
kill is a shell builtin
[root@localhost ~]# $ `which kill` --help
usage: kill [ -s signal | -p ] [ -a ] pid ...
       kill -l [ signal ]


kill如果不特别指明全路径,用的是bash的内置kill命令
shell编程是,用kill的话,最好使用全路径的kill

#################################################################################

bash shell的命令分为两类:外部命令和内部命令(build-in cmd)
1.外部命令是通过系统调用或独立的程序实现的,如sed、awk等等
2.内部命令是由特殊的文件格式(.def)所实现,如cd、history、exec等等

 
time 是 build-in cmd
time command    1>a.out  在重定向时,实际上是针对后面的命令来的,time命令本身的输出并不会被重定向的
(time command ) 1>a.out 生成一个子shell执行time command,并定向子shell的输出

exec和source都属于 built-in cmd,
输入man exec或man source可以查看所有的内部命令信息。

source:  即点(.)命令。
"Read and execute commands from filename in the current shell environment and ..."。
source命令是在当前进程中执行参数文件中的各个命令,而不是另起子进程(或sub-shell)。

exec:
"No new process is created."这就是说exec命令不产生新的子进程。那么exec与source的区别是什么呢?
exec命令在执行时会把当前的shell process关闭,然后换到后面的命令继续执行。

shell script:
    一种是在文件头加上#!/bin/sh,新产生一个shell,然后执行相应的shell scripts;
    一种是通过的source命令,在当前shell下执行命令,不再产生新的shell
阅读(4533) | 评论(1) | 转发(0) |
0

上一篇:shell多行注释

下一篇:'rm' to the Trash

给主人留下些什么吧!~~

jeen_ma2011-11-28 23:06:03

。好好写