9 Ağustos 2020 Pazar

bash kodlama - CDPATH değişkeni

Giriş
Açıklaması şöyle. cd komutu çalıştırılınca
 - Önce CDPATH değişkenine değer atanmışsa bu değer ile başlayan dizin varsa oraya gider.
- Yoksa current directory'den başlayarak belirtilen yere gitmeye çalışır.
In other words, the default behavior for cd foo is "move into the directory named 'foo' which is a subdirectory of the current directory or of any other directory that is given in CDPATH". When CDPATH is not set, cd will only look in the current directory but, when it is set, it will also look for a match in any of the directories you set it to.
Değer Atama
Şöyle yaparız
CDPATH="/path/to/dir1:/path/to/dir2:/path/to/dirN"
Örnek
Şöyle yaparız
$ echo $CDPATH    ## CDPATH is not set

$ cd etc          ## fails: there is no "etc" directory here
bash: cd: etc: No such file or directory
$ CDPATH="/"      ##CDPATH is now set to /
$ cd etc          ## This now moves us to /etc
/etc

Hiç yorum yok:

Yorum Gönder