Appendix B. Special Shell Characters and Variables

Mac OS X offers several different shells you can use to enter commands and run scripts. Chapter 2 helps you become comfortable working in the shell. This appendix provides a reference of the numerous characters and variables that have special meaning to particular shells (such as the bash shell) or are available on most shells. Many of those elements are referenced in Table B-1 (Special Shell Characters) and Table B-2 (Shell Environment Variables).

Using Special Shell Characters

You can use special characters from the shell to match multiple files, save some keystrokes, or perform special operations. Table B-1 shows some shell special characters that you may find useful.

Table B.1. Special Shell Characters

Character

Description

*

Match any string of characters.

?

Match any one character.

[ ... ]

Match any character enclosed in the braces.

" ... "

Remove special meaning of characters between quotes. Variables are not expanded.

" ... "

Same as simple quotes except for the escape characters ($ ` and \) that preserve their special meaning.

\

Escape character to remove the special meaning of the character that follows.

˜

Refers to the $HOME directory.

˜+

Value of the shell variable PWD or the working directory (bash only).

˜-

Refers to the previous working directory (bash only).

.

Refers to the current working directory.

..

Refers to the directory above the current directory. Can be used repeatedly ...

Get MAC OS® X UNIX® Toolbox: 1000+ Commands for the Mac OS® X now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.