码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本中cd命令无效

时间:2018-03-25 18:13:54      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:shell   运行时   body   gpo   test   down   dir   blog   cd命令   

对于一段包含cd 命令的shell脚本(test.sh):

#!/bin/bash
cd ..
mkdir ./test

运行:

sh ./test.sh

脚本运行时无法在上级目录建立test文件

此时用

. ./test.sh

即可

shell脚本中cd命令无效

标签:shell   运行时   body   gpo   test   down   dir   blog   cd命令   

原文地址:https://www.cnblogs.com/jerry323/p/8645411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!