[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

System User's Guide: Operating System and Devices


Types of Files

There are three basic types of files:

regular Stores data (text, binary, and executable).
directory Contains information used to access other files.
special Defines a FIFO (first-in, first-out) pipe file or a physical device.

All file types recognized by the system fall into one of these categories. However, the operating system uses many variations of these basic types.

Regular Files

Regular files are the most common files. Another name for regular files is ordinary files. Regular files contain data.

Text Files

Text files are regular files that contain information readable by the user. This information is stored in ASCII. You can display and print these files. The lines of a text file must not contain NUL characters, and none can exceed {LINE_MAX} bytes in length, including the new-line character.

The term text file does not prevent the inclusion of control or other nonprintable characters (other than NUL). Therefore, standard utilities that list text files as inputs or outputs are either able to process the special characters gracefully or they explicitly describe their limitations within their individual sections.

Binary Files

Binary files are regular files that contain information readable by the computer. Binary files might be executable files that instruct the system to accomplish a job. Commands and programs are stored in executable, binary files. Special compiling programs translate ASCII text into binary code.

The only difference between text and binary files is that text files have lines of less than {LINE_MAX} bytes, with no NUL characters, each terminated by a new-line character.

Directory Files

Directory files contain information the system needs to access all types of files, but they do not contain the actual file data. As a result, directories occupy less space than a regular file and give the file system structure flexibility and depth. Each directory entry represents either a file or a subdirectory. Each entry contains the name of the file and the file's index node reference number (i-node number). The i-node number points to the unique index node assigned to the file. The i-node number describes the location of the data associated with the file. Directories are created and controlled by a separate set of commands.

See Directory Overview for more information.

Special Files

Special files define devices for the system or temporary files created by processes. There are three basic types of special files: FIFO (first-in, first-out), block, and character. FIFO files are also called pipes. Pipes are created by one process to temporarily allow communication with another process. These files cease to exist when the first process finishes. Block and character files define devices.

Every file has a set of permissions (called access modes) that determine who can read, modify, or execute the file.

To learn more about file access modes, see File and Directory Access Modes .

File Naming Conventions

The name of each file must be unique within the directory where it is stored. This ensures that the file also has a unique path name in the file system. File-naming guidelines are:

File Path Names

The path name for each file and directory in the file system consists of the names of every directory that precedes it in the tree structure.

Since all paths in a file system originate from the /(root) directory, each file in the file system has a unique relationship to the root directory known as the absolute path name. Absolute path names begin with the slash (/) symbol. The absolute path name of file h within the Example File System is /B/C/h. Notice that there are two files named g. Because the absolute paths to these files are different, /B/g and /B/C/g, each file named g has a unique name within the system. Every component of a path name is a directory except the final component. The final component of a path name can be a file name.

Note: Path names cannot exceed 1023 characters.

Pattern Matching with Wildcards and Metacharacters

Wildcard characters provide a convenient way for specifying multiple file or directory names with one character. The two wildcard characters are asterisk (*) and question mark (?). The metacharacters are open and close square brackets ([]), hyphen (-), and exclamation mark (!).

* Wildcard

Use the * to match any sequence or string of characters. The * means any characters, including no characters. For example, if you have the following files in your directory:

1test 2test afile1 afile2 bfile1 file file1 file10 file2 file3   

and you want to refer to only to the files that begin with file, you would use:

file*

The files selected would be: file file1 file10 file2 file3

To refer to only the files that contain the word file, you would use:

*file*

The files selected would be: afile1 afile2 bfile1 file file1 file10 file2 file3

? Wildcard

Use the ? to match any one character. The ? means any single character.

To refer to only the files that start with file and end with a single character, use:

file?

The files selected would be: file1 file2 file3

To refer to only the files that start with file and end with any two characters, use:

file??

The file selected would be: file10

[ ] Shell Metacharacters

Metacharacters offer another type of wildcard notation by enclosing the desired characters within [ ]. It is like using the ?, but it allows you to choose specific characters to be matched. The [ ] also allow you to specify a range of values using the hyphen (-). To specify all the letters in the alphabet, use [[:alpha:]]. To specify all the lowercase letters in the alphabet, use [[:lower:]].

To refer to only the files that end in 1 or 2, use:

*file[12]

The files selected would be: afile1 afile2 file1 file2

To refer only to the files that start with any number, use:

[0123456789]* or [0-9]*

The files selected would be: 1test 2test

To refer only to the files that don't begin with an a, use:

[!a]*

The files selected would be: 1test 2test bfile1 file file1 file10 file2 file3

Pattern Matching versus Regular Expressions

Regular expressions allow you to select specific strings from a set of character strings. The use of regular expressions is generally associated with text processing.

Regular expressions can represent a wide variety of possible strings. While many regular expressions can be interpreted differently depending on the current locale, internationalization features provide for contextual invariance across locales.

See the examples in the following comparison between File Matching Patterns and Regular Expressions:

Pattern Matching         Regular Expression

*                       .*

?                        .

[!a]                     [^a]

[abc]                    [abc]

[[:alpha:]]              [[:alpha:]]

See the awk command in the AIX 5L Version 5.1 Commands Reference for the exact syntax.

Related Information

Commands Overview

Processes Overview

Chapter 4, Input and Output Redirection

Chapter 11, Shells

File Systems

Directory Overview

Linking Files and Directories

DOS Files

Chapter 7, Printers, Print Jobs, and Queues

Chapter 8, Backup Files and Storage Media

Chapter 9, File and System Security


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]