我编写了一些小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

08-17 23:37