1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

パスの書き方について

Last updated at Posted at 2019-11-04

ルートディレクトリ

最上位のディレクトリ

サブディレクトリ

root以外のディレクトリ

カレントディレクトリ

現在いるディレクトリ

絶対パス

ルートディレクトリからのパスを表記する

相対パス

カレントディレクトリからのパスを表記する

./ → 現在の階層を表す
../ → 1つ上の階層を表す

例1

カレントディレクトリをdir-Bとする。

問い

file-1の位置を絶対パス、相対パスで表記せよ。

root
├── dir-A
│   ├── file-1
│   └── file-2
└── dirB         ← ここにいる
    ├── dir-C
    │   ├── file-3
    │   └── file-4
    ├── dir-D
    │   ├── file-5
    │   ├── file-6
    │   ├── file-7
    │   ├── file-8
    │   └── file-9
    └── dir-E
        ├── file-10
        └── file-11

解答

絶対パス → root/dir-A/file-1

相対パス → ./dir-A/file-1 または dir-A/file-1

例2

カレントディレクトリをdir-Dとする。

問い

file-2の位置を絶対パス、相対パスで表記せよ。

root
├── dir-A
│   ├── file-1
│   └── file-2
└── dirB
    ├── dir-C
    │   ├── file-3
    │   └── file-4
    ├── dir-D      ← ここにいる
    │   ├── file-5
    │   ├── file-6
    │   ├── file-7
    │   ├── file-8
    │   └── file-9
    └── dir-E
        ├── file-10
        └── file-11

解答

絶対パス → root/dir-A/file-2

相対パス → ../dir-A/file-2

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?