当前位置: 技术问答>linux和unix
简单的shell问题
来源: 互联网 发布时间:2016-03-06
本文导语: 请问我编写shell脚本其中有cd /etc/ 但在运行脚本时为什么不会运行上面的命令呢?!谢谢 | 在shell里的工作目录改变了, 但是从sh退出后又回到了原来的当前目录. mymtom@fc6:/home/c/r/mymtom$ cat cd.sh [code=BatchF...
请问我编写shell脚本其中有cd /etc/
但在运行脚本时为什么不会运行上面的命令呢?!谢谢
但在运行脚本时为什么不会运行上面的命令呢?!谢谢
|
在shell里的工作目录改变了, 但是从sh退出后又回到了原来的当前目录.
mymtom@fc6:/home/c/r/mymtom$ cat cd.sh
[code=BatchFile]
#! /bin/sh -x
cd /
pwd
cd /etc/
pwd
[/code]
输出:
mymtom@fc6:/home/c/r/mymtom$ cat cd.sh
[code=BatchFile]
#! /bin/sh -x
cd /
pwd
cd /etc/
pwd
[/code]
输出:
mymtom@fc6:/home/c/r/mymtom$ ./cd.sh
+ cd /
+ pwd
/
+ cd /etc/
+ pwd
/etc
mymtom@fc6:/home/c/r/mymtom$