treeコマンドを打って、そういえばPhotoshopにも木を生やすフィルタがいつのまにか追加されていたなと思い出して初使用。CG臭さは否めないので、ひと工夫必要かな。

コマンドラインものがたり

Mac環境での話だけど、大体何でも似たような事でしょう。

$ cd ~/Desktop

$ tree
.

0 directories, 0 files

# -p オプションを与える事で複数階層のディレクトリを一気に作ることができる
$ mkdir -p a/b/c/d/e

$ tree
.
└── a
    └── b
        └── c
            └── d
                └── e

5 directories, 0 files

# ディレクトリ「e」に向けてシンボリックリンクを張る
$ ln -s a/b/c/d/e

$ tree
.
├── a
│   └── b
│       └── c
│           └── d
│               └── e
└── e -> a/b/c/d/e

6 directories, 0 files

# ディレクトリ「e」に移動
$ cd e

$ pwd
/Users/[user_name]/Desktop/e

# 一階層上のディレクトリ「d」に行きたい
$ cd ..

# ありゃりゃ?
$ pwd
/Users/[user_name]/Desktop

# -------------------------------------------------------------------
# 「-P」オプション使うとシンボリックリンクのターゲットパスに直接移動できる
# -------------------------------------------------------------------
$ cd -P e

# おぉー。
$ pwd
/Users/[user_name]/Desktop/a/b/c/d/e

# もちろん……
$ cd ..

# ちゃんと「d」ディレクトリにいける。
$ pwd
/Users/[user_name]/Desktop/a/b/c/d

# -------------------------------------------------------------------
# 「-P」オプションはpwdコマンドでも同様にシンボリックリンクの
# ターゲットを指すことができる
# -------------------------------------------------------------------
$ cd ~/Desktop

$ tree
.
├── a
│   └── b
│       └── c
│           └── d
│               └── e
└── e -> a/b/c/d/e

6 directories, 0 files

# もう一回シンボリックリンクで「e」ディレクトリに移動してみる
$ cd e

# オプション無しのpwdコマンド
$ pwd
/Users/[user_name]/Desktop/e

# 「-P」オプションありのpwdコマンド
$ pwd -P
/Users/[user_name]/Desktop/a/b/c/d/e

なるほどなるほど。

-Pは何のピー?

ちょっと気になったので。

$ man pwd

DESCRIPTION

The pwd utility writes the absolute path- name of the current working directory to the standard output.

Some shells may provide a builtin pwd com- mand which is similar or identical to this utility. Consult the builtin(1) manual page.

The options are as follows:

-L Display the logical current work- ing directory.

-P Display the physical current work- ing directory (all symbolic links resolved).

If no options are specified, the -L option is assumed.

……フィジカルのPっぽいですね。
パスのPかと想像してたけど、これでまた賢くなったね!