[Next] [Previous] [Up] [Top] [Contents] [Index]
Chapter 2: Getting Started on a UNIX System
The backslash (\) character is used on the UNIX command line to mask the special meaning of the character immediately following it (no spaces in-between) so that the command interpreter takes the character literally. It is called a quoting character. For example:
% command \<CR>
causes the carriage return to be ignored, allowing you to continue typing your command on the following line.
The forward slash (/) character is the symbol for the root directory. In path names it acts as a separator between directories in the hierarchy, and between the last directory and the file, if one is specified. For example:
/rootdir/.../userdir/subdir1/subdir2/filename
Different types of quotes have special meanings.
Normal single quotes (apostrophes) around a string ('string') tell the command interpreter to take the string (string) literally. Double quotes around a string ("string") also tell the command interpreter to take the string literally, but allow interpretation of variables that follow a $ character ($ preceding a variable name outputs the value of the variable; see section 9.1). Section 5.1.2 further explains single and double quotes in command interpretation, and provides an example.
Single backquotes around a command string (`string`) tell the interpreter to run the command(s) in the string, and to use the output of the command(s) in place of the string itself. This is useful for combining two commands into one, and for doing iterative tasks within shell scripts (shell scripts are introduced in section 4.4).
A string of commands enclosed in parentheses (e.g., (command1;command2)) is run in a subshell. In section 5.1.1 we discuss the difference between shell commands and non-shell commands. A non-shell command always runs in a separate shell (a subshell); when enclosed in parentheses, the command starts a second subshell.
The semicolon (;) character separates successive commands on a single command line. For example,
% command1 ; command2
executes command1, and when it finishes, command2 gets executed.
The ampersand character (&) is similar to ; but does not wait for command1 to finish.
A double ampersand (&&) runs command2 only if command1 was successful.
Piping commands (the pipe symbol |) is discussed in section 5.4.3. A pipe tells command2 to use the output of command1 as input.
A double pipe (||) runs command2 only if command1 was unsuccessful.
Special characters are used in file expansion (section 6.2.2). Note that to prevent file expansion, these characters must be prefaced by a backslash (\). Metacharacters are also used in input/output redirection (section 5.4.2), and in regular expressions (section 5.4.5) as wildcards, delimiters, and other special pattern-matching characters. Refer to these sections for specific information.