对于一段包含cd 命令的shell脚本(test.sh): #!/bin/bash cd .. mkdir ./test 运行: sh ./test.sh 脚本运行时无法在上级目录建立test文件 此时用 . ./test.sh 即可 文章来源: shell脚本中cd命令无效 标签 shell test 运行命令 shell脚本