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

后端 未结 30 2376
眼角桃花
眼角桃花 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:40

    On my particular case i needed too many times to change for the same directory. So on my .bashrc (I use ubuntu) i've added the

    1 -

    $ nano ~./bashrc

     function switchp
     {
        cd /home/tree/projects/$1
     }
    

    2-

    $ source ~/.bashrc

    3 -

    $ switchp java

    Directly it will do: cd /home/tree/projects/java

    Hope that helps!

提交回复
热议问题