Files and Directories

When you create a file, it's best to stick with "safe" characters in the name, such as letters, digits, and underscore. Periods and dashes are okay, too, but it's best not to use them as the first character of a filename. Letter case is significant in UNIX filenames, so junk, Junk, and JUNK refer to different files.

A directory is a special kind of file that's used to hold other files (including other directories). The directory in which you find yourself when you first log in is called your home directory. Directories help you organize your work because you can group sets of related files into separate directories. That way you don't need to keep everything in your home directory—a sure way to create an intractable mess.

Filename Patterns

When you want to specify several files on a command line, typing all the names explicitly quickly becomes annoying. Often, you can save keystrokes by using filename patterns. The shell interprets the patterns and finds matching filenames. Filename patterns are described briefly below. For more information, see Chapter 9, File-Naming Shortcuts.

The shell provides the following pattern-matching operators:

*

Match any string of characters. * by itself matches any filename; a* matches filenames beginning with a; *z matches filenames ending in z; a*z matches filenames beginning with a and ending in z; *a* matches filenames containing a anywhere in the filename.

?

Match any single character. ??? matches 3-character filenames; part? ...

Get Using csh & tcsh 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.