определить тип файла (determine file type)
Стандартный вывод (Stdout)
In the POSIX locale, the following format shall be used to
identify each operand, file specified:
"%s: %s\n", <file>, <type>
The values for <type> are unspecified, except that in the POSIX
locale, if file is identified as one of the types listed in the
following table, <type> shall contain (but is not limited to) the
corresponding string, unless the file is identified by a
position-sensitive test specified by a -M
or -m
option. Each
<space> shown in the strings shall be exactly one <space>.
Table 4-9: File Utility Output Strings
───────┬─────────────────────────────────────────────┬──────────────────────────────────┬─ │
│ If
file is: <
type│> shall contain the string: Notes
│ │
───────┼─────────────────────────────────────────────┼──────────────────────────────────┼─ │
Nonexi│stent canno│t open │ │
│ │ │ │
│Block special │ block special │ 1 │
│Character special │ character special │ 1 │
│Directory │ directory │ 1 │
│FIFO │ fifo │ 1 │
│Socket │ socket │ 1 │
│Symbolic link │ symbolic link to │ 1 │
│Regular file │ regular file │ 1,2 │
│Empty regular file │ empty │ 3 │
│Regular file that cannot be read │ cannot open │ 3 │
│ │ │ │
│Executable binary │ executable │ 3,4,6 │
│ar archive library (see ar) │ archive │ 3,4,6 │
│Extended cpio format (see pax) │ cpio archive │ 3,4,6 │
│Extended tar format (see ustar
in pax) │ tar archive │ 3,4,6 │
│ │ │ │
│Shell script │ commands text │ 3,5,6 │
│C-language source │ c program text │ 3,5,6 │
│FORTRAN source │ fortran program text │ 3,5,6 │
│ │ │ │
│Regular file whose type cannot be determined │ data │ 3 │
└─────────────────────────────────────────────┴──────────────────────────────────┴───────┘
Notes:
1. This is a file type test.
2. This test is applied only if the -i
option is
specified.
3. This test is applied only if the -i
option is not
specified.
4. This is a position-sensitive default system test.
5. This is a context-sensitive default system test.
6. Position-sensitive default system tests and
context-sensitive default system tests are not
applied if the -M
option is specified unless the -d
option is also specified.
In the POSIX locale, if file is identified as a symbolic link
(see the -h
option), the following alternative output format
shall be used:
"%s: %s %s\n", <file>, <type>, <contents of link>"
If the file named by the file operand does not exist, cannot be
read, or the type of the file named by the file operand cannot be
determined, this shall not be considered an error that affects
the exit status.