bash - 留在 bash 脚本结束后更改的目录中

标签 bash shell cd

我的 bash 脚本:

#!/bin/bash
cd /tmp

在运行我的脚本之前:

pwd: /

运行我的脚本后:

pwd: /

在通过采购运行我的脚本后:

pwd: /tmp

我如何在不获取脚本的情况下留在脚本的路径上?

最佳答案

你不能。对当前目录的更改只会影响当前进程。

关于bash - 留在 bash 脚本结束后更改的目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4461633/

相关文章:

bash - Bash脚本错误检查

linux - 在shell中如何处理/usr/sbin和/usr/local/sbin?

Linux Shell 脚本 : Script Check

bash - 在期望脚本中转义$

linux - 前缀搜索名称以在 bash 中输出

bash - 打印标准时间 - 例如 04 :52:06 PM - Bash

linux - 运行 shell 脚本时定义变量?

bash - 运行 cd 时 Shell 脚本认为目录不存在

linux - cron 调度程序如何 cd 到某个位置并执行 shell 脚本

bash - 具有 STDERR/STDOUT 重定向的 eval 命令导致问题