LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 740|回复: 2

这几种执行方式有何区别

[复制链接]
发表于 2005-5-4 22:27:07 | 显示全部楼层 |阅读模式
  第一种 : 将hello这个档案的权限设定为可执行。 
  [foxman@foxman bash]# chmod 755 hello 
  执行 
  [foxman@foxman bash]# ./hello 
  hello world 

  *************************

  第二种 : 使用bash内建指令"source"或"."。 
  [foxman@foxman bash]# source hello 
  hello world 
  或 
  [foxman@foxman bash]# . hello 
  hello world 

  *************************

  第三种 : 直接使用sh/bash/tcsh指令来执行。 
  [foxman@foxman bash]# sh hello 
  hello world 
  或 
  [foxman@foxman bash]# bash hello 
  hello world 
这几种执行方式有何区别
发表于 2005-5-5 02:23:42 | 显示全部楼层
1,3是在一个子shell里运行你的脚本,2是在当前shell运行你的脚本
回复 支持 反对

使用道具 举报

发表于 2005-5-5 13:37:22 | 显示全部楼层
source hello=. ./hello就是在当前的shell中执行
exec hello也是在当前shell中执行,但跟上一个的区别就是执行完后就退出shell
sh hello=./hello就是在一个子shell中执行
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表