Why I can't change directories using “cd”?

后端 未结 30 2366
眼角桃花
眼角桃花 2020-11-21 06:17

I\'m trying to write a small script to change the current directory to my project directory:

#!/bin/bash
cd /home/tree/projects/java

I save

30条回答
  •  灰色年华
    2020-11-21 06:24

    I got my code to work by using.

    ./ dose not work because it doesn't change your directory in the terminal it just changes the directory specific to that script.

    Here is my program

    #!/bin/bash 
    echo "Taking you to eclipse's workspace."
    cd /Developer/Java/workspace
    

    Here is my terminal

    nova:~ Kael$ 
    nova:~ Kael$ . workspace.sh
    Taking you to eclipe's workspace.
    nova:workspace Kael$ 
    

提交回复
热议问题