简体   繁体   English

为什么我的CD无法在bash中工作?

[英]Why is my cd not working in bash?

I have written small bash to automate my code 我写了小bash来自动化我的代码

#!/bin/bash

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

The exe file is Occam2d and input file is start.txt. exe文件为Occam2d,输入文件为start.txt。 When I run my script I got 当我运行脚本时,我得到了

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

Why? 为什么?

With @anubhava's comment: 带有@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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM