Specify files and folders in Terminal on Mac
Most commands operate on files and folders, whose locations are identified by paths. The folder names that make up a path are separated by slashes. For example, the path to the Terminal app is /Applications/Utilities/Terminal.app.
The following table shows standard shortcuts used to represent specific folders. They are specified relative to the current folder, and can eliminate the need to enter full paths.
Shortcut | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
. | A single period represents the current folder. For example, the string “./Test.c” represents the Test.c file in the current folder. | ||||||||||
.. | Two periods represent the parent folder of the current folder. For example, the string “../Test” represents a sibling folder (named Test) of the current folder. | ||||||||||
~[username] | The tilde character represents the home folder of the logged-in user. For example, to specify the Documents folder of the current user, enter ~/Documents. To specify another user’s Document folder, use the short name preceded by the tilde (~) character—for example, ~jsmith/Documents. In macOS, this folder is in the local /Users folder or on a network server. For a list of short names on your server, enter |
File and folder names can include letters, numbers, a period, or the underscore character. Avoid most other characters, including space characters. Although some file systems permit the use of these other characters, including spaces, you might need to add single or double quotation marks around pathnames that contain them.
For individual characters, you can also use an escape character—that is, put a backslash character immediately before the character in your string. For example, the pathname My Disk is “My Disk” or My\ Disk.