# | スクリプト | 解説 | |
---|---|---|---|
1 | #! /bin/bash | # | |
2 | # serch directory of cd | # | |
3 | IFS=: | 区切り文字を空白からコロン(:)に変更 | |
4 | for n in $CDPATH | CDPATH の内容を列挙型させる($IFSで分離) | |
5 | do | # | |
6 | if [ -d $n/$1 ]; then | CDPATHのディレクトリ以下に引数で指定した サブディレクトリが存在すれば真 | |
7 | (cd $n/$1; pwd ) | 上記で判定したディレクトリに移動し、ディレクトリを表示 | |
8 | fi | # | |
9 | done | # |
$ echo $CDPATH /home/ycos/:/etc/:/etc/sysconfig $ where bin /home/ycos/bin $ where httpd /etc/httpd $ where network-scripts /etc/sysconfig/network-scripts