• Global Nav Open MenuGlobal Nav Close Menu
  • Apple
Search Support
Cancel
  • Apple
  • Mac
  • iPad
  • iPhone
  • TV
  • Music
  • Support
  • Where to Buy
Terminal User Guide
Open MenuClose Menu
  • Communities
  • Contact Support
macOS Catalina 10.15
macOS Mojave 10.14
macOS High Sierra
Table of Contents

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 dscl . -list /Users. Most of these users aren’t traditional user accounts with home directories, but you should be able to find the short name of known users on the computer.

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.

See alsoExecute commands and run tools in Terminal on MacRedirect Terminal input and output on MacApple Developer website: Command Line Primer
Apple
  1. Support
  2. Terminal User Guide
  3. Specify files and folders in Terminal on Mac
Guinea-Bissau
Copyright © 2019 Apple Inc. All rights reserved.
Terms of Use Site Map