1. Computing & Technology

Discuss in my forum

File Names

By , About.com Guide

command export FOO=rms/hacks to set up an environment variable named FOO, then you can use /u/$FOO/test.c or /u/${FOO}/test.c as an abbreviation for /u/rms/hacks/test.c. The environment variable name consists of all the alphanumeric characters after the $; alternatively, it may be enclosed in braces after the $. Note that shell commands to set environment variables affect Emacs only if done before Emacs is started.

You can use the ~/ in a file name to mean your home directory, or ~user-id/ to mean the home directory of a user whose login name is user-id. (On DOS and Windows systems, where a user doesn't have a home directory, Emacs substitutes ~/ with the value of the environment variable HOME; see General Variables.)

To access a file with $ in its name, type $$. This pair is converted to a single $ at the same time as variable substitution is performed for a single $. Alternatively, quote the whole file name with /: (see Quoted File Names). File names which begin with a literal ~ should also be quoted with /:.

The Lisp function that performs the substitution is called substitute-in-file-name. The substitution is performed only on file names read as such using the minibuffer.

You can include non-ASCII characters in file names if you set the variable file-name-coding-system to a non-nil value. See Specify Coding.

©2012 About.com. All rights reserved.

A part of The New York Times Company.