Next / Previous / Index / TCC Help System / Publications / Site map / NM Tech homepage

What is a relative pathname?

Tech Computer Center logo

To refer to a file in a subdirectory of the current working directory, use the name of the subdirectory followed by a slash (/) and the name of the file. For example, to display a file called rain in a subdirectory called red that is located in the current directory:

    % cat red/rain

To refer to a file in the parent directory of the current directory, use "../" followed by the name of the file. For example, the pathname "../rowr" would refer to a file named rowr in the parent of the current working directory. Pathname "../../b" would refer to a file named b in the directory two levels above.

Here is the general procedure for forming a relative pathname:

  1. If the destination is not below the current directory, start with one "../" for each level you have to move up the file tree until you reach a directory that is above the target.
  2. List all the directories going back down the tree, separated by slashes.
  3. End with the name of the target file.

Next: What is a home-relative pathname?
See also: What is a pathname?
Previous: What is an absolute pathname?
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Computer Center: Help System
TCC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman, john@nmt.edu
Last updated: 1995/12/04 19:39:34 UT
URL: http://www.nmt.edu/tcc/help/unix/relpath.html
QR two-dimensional bar code