[RUBY] Pass type

path

A path is a string that indicates the location of a directory or file. Separate directories by / (slash) for each hierarchy. How to specify the path There are two paths: ** absolute path ** and ** relative path **.

パス.png

The difference between GUI such as Finder and showing by path is It's similar to the difference between pointing to a location based on a map and telling the address of that location.

The following describes ** absolute paths ** and ** relative paths **.

Absolute path

** Absolute path is the path specified from the root directory. ** ** The root directory for all Mac directories is / (slash). All directories and files will be traced from here. Therefore, when specifying an absolute path, specify / (slash) at the very beginning of the path.

Example: Absolute path

/Users/User name/Desktop

** Here, don't confuse the first / (slash) </ font> to point to the root directory and the second and subsequent / to represent the hierarchy delimiters. be careful. ** **

Also, / Users / username </ font> is your home directory and can be represented as ** ~ </ font> **, so your home The path of the directory below the directory can also be indicated by the absolute path as shown below.

Example: Absolute path

~/Desktop

絶対.png

The absolute path can be moved to the specified location no matter what directory you are working in. However, since the path must be specified by tracing from the root directory, the description may become long.

Relative path

** Relative path is the path specified from the current directory. Do not start the path with a / (slash) as it is not specified from the root directory. ** **

If it is a directory or file directly under the current directory, you can easily specify the path without specifying what kind of directory hierarchy it is in.

Relative path

#Specifies the desktop location if the current directory is your home directory
Desktop

#Specifies the location of files on the desktop if the current directory is your home directory
Desktop/Note.txt

相対.png

Relative paths have the advantage of making it possible to simply specify the path. However, depending on where the current directory is, you will need to change the path you specify.

These paths are a necessary knowledge as a way to show the hierarchy, but in the terminal If it is only the path, nothing can be ordered. The path is used in combination with the instruction to the PC.

Summary

** Absolute path is the path specified from the root directory. Relative path is the path specified from the current directory. ** **

For example, when giving directions to someone, the absolute pass is to directly tell the address as "○○ ward, Tokyo △△ city ...". It can be said that the relative path is to think from the current location of the other party and convey something like "Go straight from there and turn two corners to the left ...".

that's all.