
shell
captJacklee
写代码比打游戏还爽!
展开
-
source、sh、bash、./执行脚本的区别
1.source命令用法: source FileName 作用:在当前bash环境下读取并执行FileName中的命令。该filename文件可以无"执行权限" 注:该命令通常用命令“.”来替代。 如:source .bash_profile . .bash_profile两者等效。 source(或点)命令通常原创 2017-09-18 14:56:18 · 707 阅读 · 0 评论 -
shell脚本常用命令
basename 1. basename 是去除目录后剩下的名字 example: shell> temp=/home/temp/1.test shell> base=`basename $temp` shell> echo $base 结果为:1.test 2. dirname 是取目录 example: shell> temp=/home/temp/1.test shell原创 2017-09-18 17:05:43 · 1175 阅读 · 0 评论 -
shell脚本的三种调用方式
在运行shell脚本时候,有三种方式来调用外部的脚本,exec(exec script.sh)、source(source script.sh)、fork(./script.sh) 1、exec(exec /home/script.sh): 使用exec来调用脚本,被执行的脚本会继承当前shell的环境变量。但事实上exec产生了新的进程,他会把主shell的进程资源占用并替换原创 2017-09-18 17:24:42 · 1190 阅读 · 0 评论