linux - 为什么我的 cd 不能在 bash 中工作?

标签 linux bash shell

我已经编写了小型 bash 来自动化我的代码

#!/bin/bash

jhome () {
cd /home/milenko/OCCAM2DMT_V3.0/cifort
}
./Occam2D start.txt

exe文件是Occam2d,输入文件是start.txt。 当我运行我的脚本时,我得到了

bash a.sh
a.sh: line 6: ./Occam2D: No such file or directory

为什么?

最佳答案

加上@anubhava 的评论:

#!/bin/bash

jhome () {
  cd /home/milenko/OCCAM2DMT_V3.0/cifort
}

# call your function to change directory
# and only if cd was successful run ./Occam2D
jhome && ./Occam2D start.txt

关于linux - 为什么我的 cd 不能在 bash 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36754738/

相关文章:

shell - 如何将变量从 Jenkinsfile 传递给 shell 命令

linux - 导出 PATH 在 Linux 上的 bash shell 中不起作用

linux - Linux中带有ECHO命令的-n选项

regex - 仅当第二列中的内容为正数时才返回输出的所有列

linux - awk 要求合并两个文件

objective-c - 从 cocoa (obj.c) 执行 shell 脚本并响应

linux - 启动 .desktop 文件时如何包含我的 bash 路径

linux - 在 Linux shell 上终止另一个函数内的函数

linux - 如何运行命令,该命令在后台执行另一个运行脚本的终端

shell - 如何 grep 包含一些二进制数据的文本文件?