How do i use $CDPATH in bash?



  • Man page for bash.

    CDPATH is what PATH is for binaries, it is a search path for directories.
    When it is not set

    $ cd doc
    bash: cd: doc: No such file or directory
    

    When set. You can set it in your .bashrc.

    $ CDPATH=/usr/local:/usr/share
    

    Then change directory to some directory inside /usr/local for instance.

    $ cd bin
    /usr/local/bin
    $ 
    $ cd etc
    /usr/local/etc
    

    Now you do not have to use full path names, for locations you use frequently.



© Lightnetics 2024