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

System User's Guide: Operating System and Devices

Types of Files

The following basic types of files exist:

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 and are used to contain data. Regular files are in the form of text files or binary files:

Text Files

Text files are regular files that contain information stored in ASCII and readable by the user. 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 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.

Text and binary files differ only in that text files have lines of less than {LINE_MAX} bytes, with no NUL characters, each terminated by a newline character.

Directory Files

Directory files contain information that the system needs to access all types of files, but directory files 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.

Special Files

Special files define devices for the system or temporary files created by processes. The basic types of special files are 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.

Because 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. For example, the absolute path name of file h could be/B/C/h. Notice that two files named h can exist in the system. Because the absolute paths to the two files are different, /B/h and /B/C/h, each file named h 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 in length.

Pattern Matching with Wildcards and Metacharacters

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

Using the * Wildcard Charactor

Use the asterisk (*) to match any sequence or string of characters. The (*) indicates 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 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

Using the ? Wildcard Charactor

Use the ? to match any one character. The ? indicates 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

Using [ ] 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 to only the files that start with any number, use:

[0123456789]* or [0-9]*

The files selected would be: 1test 2test

To refer to only the files that do not 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.2 Commands Reference for the exact syntax.

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