Determining file type (file) – HP NonStop G-Series User Manual

Page 111

Advertising
background image

The third field for each entry, the number to the left of the user name, represents the number of
links to that inode-number. Notice that file3 and checkfile have the same i-number, 1079,
and that both show two links. Each time the rm command removes a filename, it reduces the
number of links to that inode-number by one.

In the following example, use the rm command to remove the filename checkfile:

$ rm checkfile

Now, list the contents of the directory with the ls -il command. Notice that the rm command
has reduced the number of links to inode-number 1079, which is the same i-number that file3
is linked to, by one.

$ ls -il

total 13

1077 -rw-r--r-- 1 larry system 101 Jun 5 10:03 file1

1078 -rw-r--r-- 1 larry system 75 Jun 5 10:03 file2

1079 -rw-r--r-- 1 larry system 65 Jun 5 10:06 file3

1080 drwxr-xr-x 2 larry system 32 Jun 5 10:07 project

Determining File Type (file)

Use the file command when you want to find out what kind of data a file contains without having
to display its contents. The file command displays all of the following:

Text files

Directories

Source code files for a programming language

Executable files

The file command is especially useful when you suspect that a file contains a compiled program.

Following is the general format of the file command:

file filename

The filename entry can be the name of the file, the relative pathname of the file, the absolute
pathname of the file, or a list of filenames. The format you use depends on where the file is located
in relation to your current directory. You can also use pattern-matching characters to specify files.

For example, to determine the file type of entries in your home directory, enter the following
(remember that your own home directory will appear instead of /u/uname):

$ cd

$ pwd

/u/uname

$ file *

file1: ascii text

file2: ascii text

file3: ascii text

project: directory

reports: directory

Determining File Type (file)

111

Advertising
This manual is related to the following products: