logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

file.1p (23562B)


  1. '\" et
  2. .TH FILE "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. file
  12. \(em determine file type
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. file \fB[\fR-dh\fB] [\fR-M \fIfile\fB] [\fR-m \fIfile\fB] \fIfile\fR...
  17. .P
  18. file -i \fB[\fR-h\fB] \fIfile\fR...
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. .IR file
  23. utility shall perform a series of tests in sequence on each specified
  24. .IR file
  25. in an attempt to classify it:
  26. .IP " 1." 4
  27. If
  28. .IR file
  29. does not exist, cannot be read, or its file status could not be
  30. determined, the output shall indicate that the file was processed, but
  31. that its type could not be determined.
  32. .IP " 2." 4
  33. If the file is not a regular file, its file type shall be identified.
  34. The file types directory, FIFO, socket, block special, and character
  35. special shall be identified as such. Other implementation-defined file
  36. types may also be identified. If
  37. .IR file
  38. is a symbolic link, by default the link shall be resolved and
  39. .IR file
  40. shall test the type of file referenced by the symbolic link. (See the
  41. .BR \-h
  42. and
  43. .BR \-i
  44. options below.)
  45. .IP " 3." 4
  46. If the length of
  47. .IR file
  48. is zero, it shall be identified as an empty file.
  49. .IP " 4." 4
  50. The
  51. .IR file
  52. utility shall examine an initial segment of
  53. .IR file
  54. and shall make a guess at identifying its contents based on
  55. position-sensitive tests. (The answer is not guaranteed to be correct;
  56. see the
  57. .BR \-d ,
  58. .BR \-M ,
  59. and
  60. .BR \-m
  61. options below.)
  62. .IP " 5." 4
  63. The
  64. .IR file
  65. utility shall examine
  66. .IR file
  67. and make a guess at identifying its contents based on context-sensitive
  68. default system tests. (The answer is not guaranteed to be correct.)
  69. .IP " 6." 4
  70. The file shall be identified as a data file.
  71. .P
  72. If
  73. .IR file
  74. does not exist, cannot be read, or its file status could not be
  75. determined, the output shall indicate that the file was processed, but
  76. that its type could not be determined.
  77. .P
  78. If
  79. .IR file
  80. is a symbolic link, by default the link shall be resolved and
  81. .IR file
  82. shall test the type of file referenced by the symbolic link.
  83. .SH OPTIONS
  84. The
  85. .IR file
  86. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  87. .IR "Section 12.2" ", " "Utility Syntax Guidelines",
  88. except that the order of the
  89. .BR \-m ,
  90. .BR \-d ,
  91. and
  92. .BR \-M
  93. options shall be significant.
  94. .P
  95. The following options shall be supported by the implementation:
  96. .IP "\fB\-d\fP" 10
  97. Apply any position-sensitive default system tests and
  98. context-sensitive default system tests to the file. This is the
  99. default if no
  100. .BR \-M
  101. or
  102. .BR \-m
  103. option is specified.
  104. .IP "\fB\-h\fP" 10
  105. When a symbolic link is encountered, identify the file as a symbolic
  106. link. If
  107. .BR \-h
  108. is not specified and
  109. .IR file
  110. is a symbolic link that refers to a nonexistent file,
  111. .IR file
  112. shall identify the file as a symbolic link, as if
  113. .BR \-h
  114. had been specified.
  115. .IP "\fB\-i\fP" 10
  116. If a file is a regular file, do not attempt to classify the type of the
  117. file further, but identify the file as specified in the STDOUT section.
  118. .IP "\fB\-M\ \fIfile\fR" 10
  119. Specify the name of a file containing position-sensitive tests that
  120. shall be applied to a file in order to classify it (see the EXTENDED
  121. DESCRIPTION). No position-sensitive default system tests nor
  122. context-sensitive default system tests shall be applied unless the
  123. .BR \-d
  124. option is also specified.
  125. .IP "\fB\-m\ \fIfile\fR" 10
  126. Specify the name of a file containing position-sensitive tests that
  127. shall be applied to a file in order to classify it (see the EXTENDED
  128. DESCRIPTION).
  129. .P
  130. If the
  131. .BR \-m
  132. option is specified without specifying the
  133. .BR \-d
  134. option or the
  135. .BR \-M
  136. option, position-sensitive default system tests shall be applied after
  137. the position-sensitive tests specified by the
  138. .BR \-m
  139. option. If the
  140. .BR \-M
  141. option is specified with the
  142. .BR \-d
  143. option, the
  144. .BR \-m
  145. option, or both, or the
  146. .BR \-m
  147. option is specified with the
  148. .BR \-d
  149. option, the concatenation of the position-sensitive tests specified by
  150. these options shall be applied in the order specified by the appearance
  151. of these options. If a
  152. .BR \-M
  153. or
  154. .BR \-m
  155. .IR file
  156. option-argument is
  157. .BR \- ,
  158. the results are unspecified.
  159. .SH OPERANDS
  160. The following operand shall be supported:
  161. .IP "\fIfile\fR" 10
  162. A pathname of a file to be tested.
  163. .SH STDIN
  164. The standard input shall be used if a
  165. .IR file
  166. operand is
  167. .BR '\-'
  168. and the implementation treats the
  169. .BR '\-'
  170. as meaning standard input.
  171. Otherwise, the standard input shall not be used.
  172. .SH "INPUT FILES"
  173. The
  174. .IR file
  175. can be any file type.
  176. .SH "ENVIRONMENT VARIABLES"
  177. The following environment variables shall affect the execution of
  178. .IR file :
  179. .IP "\fILANG\fP" 10
  180. Provide a default value for the internationalization variables that are
  181. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  182. .IR "Section 8.2" ", " "Internationalization Variables"
  183. for the precedence of internationalization variables used to determine
  184. the values of locale categories.)
  185. .IP "\fILC_ALL\fP" 10
  186. If set to a non-empty string value, override the values of all the
  187. other internationalization variables.
  188. .IP "\fILC_CTYPE\fP" 10
  189. Determine the locale for the interpretation of sequences of bytes of
  190. text data as characters (for example, single-byte as opposed to
  191. multi-byte characters in arguments and input files).
  192. .IP "\fILC_MESSAGES\fP" 10
  193. .br
  194. Determine the locale that should be used to affect the format and
  195. contents of diagnostic messages written to standard error and
  196. informative messages written to standard output.
  197. .IP "\fINLSPATH\fP" 10
  198. Determine the location of message catalogs for the processing of
  199. .IR LC_MESSAGES .
  200. .SH "ASYNCHRONOUS EVENTS"
  201. Default.
  202. .SH STDOUT
  203. In the POSIX locale, the following format shall be used to identify
  204. each operand,
  205. .IR file
  206. specified:
  207. .sp
  208. .RS 4
  209. .nf
  210. "%s: %s\en", <\fIfile\fR>, <\fItype\fR>
  211. .fi
  212. .P
  213. .RE
  214. .P
  215. The values for <\fItype\fP> are unspecified, except that in the POSIX
  216. locale, if
  217. .IR file
  218. is identified as one of the types listed in the following table,
  219. <\fItype\fP> shall contain (but is not limited to) the corresponding
  220. string, unless the file is identified by a position-sensitive test
  221. specified by a
  222. .BR \-M
  223. or
  224. .BR \-m
  225. option. Each
  226. <space>
  227. shown in the strings shall be exactly one
  228. <space>.
  229. .br
  230. .sp
  231. .ce 1
  232. \fBTable 4-9: File Utility Output Strings\fR
  233. .TS
  234. center tab(@) box;
  235. cB | cB | cB
  236. l | l | l.
  237. If \fIfile\fP is:@<\fItype\fP> shall contain the string:@Notes
  238. _
  239. Nonexistent@cannot open
  240. .P
  241. Block special@block special@1
  242. Character special@character special@1
  243. Directory@directory@1
  244. FIFO@fifo@1
  245. Socket@socket@1
  246. Symbolic link@symbolic link to@1
  247. Regular file@regular file@1,2
  248. Empty regular file@empty@3
  249. Regular file that cannot be read@cannot open@3
  250. .P
  251. Executable binary@executable@3,4,6
  252. \fIar\fR archive library (see \fIar\fP)@archive@3,4,6
  253. Extended \fIcpio\fP format (see \fIpax\fP)@cpio archive@3,4,6
  254. Extended \fItar\fP format (see \fBustar\fP in \fIpax\fP)@tar archive@3,4,6
  255. .P
  256. Shell script@commands text@3,5,6
  257. C-language source@c program text@3,5,6
  258. FORTRAN source@fortran program text@3,5,6
  259. .P
  260. Regular file whose type cannot be determined@data@3
  261. .TE
  262. .TP 10
  263. .BR Notes:
  264. .RS 10
  265. .IP " 1." 4
  266. This is a file type test.
  267. .IP " 2." 4
  268. This test is applied only if the
  269. .BR \-i
  270. option is specified.
  271. .IP " 3." 4
  272. This test is applied only if the
  273. .BR \-i
  274. option is not specified.
  275. .IP " 4." 4
  276. This is a position-sensitive default system test.
  277. .IP " 5." 4
  278. This is a context-sensitive default system test.
  279. .IP " 6." 4
  280. Position-sensitive default system tests and context-sensitive
  281. default system tests are not applied if the
  282. .BR \-M
  283. option is specified unless the
  284. .BR \-d
  285. option is also specified.
  286. .RE
  287. .P
  288. .P
  289. In the POSIX locale, if
  290. .IR file
  291. is identified as a symbolic link (see the
  292. .BR \-h
  293. option), the following alternative output format shall be used:
  294. .sp
  295. .RS 4
  296. .nf
  297. "%s: %s %s\en", <\fIfile\fR>, <\fItype\fR>, <\fIcontents of link\fR>"
  298. .fi
  299. .P
  300. .RE
  301. .P
  302. If the file named by the
  303. .IR file
  304. operand does not exist, cannot be read, or the type of the file named
  305. by the
  306. .IR file
  307. operand cannot be determined, this shall not be considered an error
  308. that affects the exit status.
  309. .SH STDERR
  310. The standard error shall be used only for diagnostic messages.
  311. .SH "OUTPUT FILES"
  312. None.
  313. .SH "EXTENDED DESCRIPTION"
  314. A file specified as an option-argument to the
  315. .BR \-m
  316. or
  317. .BR \-M
  318. options shall contain one position-sensitive test per line, which shall
  319. be applied to the file. If the test succeeds, the message field of the
  320. line shall be printed and no further tests shall be applied, with the
  321. exception that tests on immediately following lines beginning with a
  322. single
  323. .BR '>'
  324. character shall be applied.
  325. .P
  326. Each line shall be composed of the following four
  327. <tab>-separated
  328. fields. (Implementations may allow any combination of one or more
  329. white-space characters other than
  330. <newline>
  331. to act as field separators.)
  332. .IP "\fIoffset\fP" 10
  333. An unsigned number (optionally preceded by a single
  334. .BR '>'
  335. character) specifying the
  336. .IR offset ,
  337. in bytes, of the value in the file that is to be compared against the
  338. .IR value
  339. field of the line. If the file is shorter than the specified offset,
  340. the test shall fail.
  341. .RS 10
  342. .P
  343. If the
  344. .IR offset
  345. begins with the character
  346. .BR '>' ,
  347. the test contained in the line shall not be applied to the file unless
  348. the test on the last line for which the
  349. .IR offset
  350. did not begin with a
  351. .BR '>'
  352. was successful. By default, the
  353. .IR offset
  354. shall be interpreted as an unsigned decimal number. With a leading 0x
  355. or 0X, the
  356. .IR offset
  357. shall be interpreted as a hexadecimal number; otherwise, with a leading
  358. 0, the
  359. .IR offset
  360. shall be interpreted as an octal number.
  361. .RE
  362. .IP "\fItype\fP" 10
  363. The type of the value in the file to be tested. The type shall consist
  364. of the type specification characters
  365. .BR d ,
  366. .BR s ,
  367. and
  368. .BR u ,
  369. specifying signed decimal, string, and unsigned decimal, respectively.
  370. .RS 10
  371. .P
  372. The
  373. .IR type
  374. string shall be interpreted as the bytes from the file starting at the
  375. specified
  376. .IR offset
  377. and including the same number of bytes specified by the
  378. .IR value
  379. field. If insufficient bytes remain in the file past the
  380. .IR offset
  381. to match the
  382. .IR value
  383. field, the test shall fail.
  384. .P
  385. The type specification characters
  386. .BR d
  387. and
  388. .BR u
  389. can be followed by an optional unsigned decimal integer that specifies
  390. the number of bytes represented by the type. The type specification
  391. characters
  392. .BR d
  393. and
  394. .BR u
  395. can be followed by an optional
  396. .BR C ,
  397. .BR S ,
  398. .BR I ,
  399. or
  400. .BR L ,
  401. indicating that the value is of type
  402. .BR char ,
  403. .BR short ,
  404. .BR int ,
  405. or
  406. .BR long ,
  407. respectively.
  408. .P
  409. The default number of bytes represented by the type specifiers
  410. .BR d ,
  411. .BR f ,
  412. and
  413. .BR u
  414. shall correspond to their respective C-language types as follows. If
  415. the system claims conformance to the C-Language Development Utilities
  416. option, those specifiers shall correspond to the default sizes used in
  417. the
  418. .IR c99
  419. utility. Otherwise, the default sizes shall be implementation-defined.
  420. .P
  421. For the type specifier characters
  422. .BR d
  423. and
  424. .BR u ,
  425. the default number of bytes shall correspond to the size of a basic
  426. integer type of the implementation. For these specifier
  427. characters, the implementation shall support values of the optional
  428. number of bytes to be converted corresponding to the number of bytes in
  429. the C-language types
  430. .BR char ,
  431. .BR short ,
  432. .BR int ,
  433. or
  434. .BR long .
  435. These numbers can also be specified by an application as the characters
  436. .BR C ,
  437. .BR S ,
  438. .BR I ,
  439. and
  440. .BR L ,
  441. respectively. The byte order used when interpreting numeric values is
  442. implementation-defined, but shall correspond to the order in which a
  443. constant of the corresponding type is stored in memory on the system.
  444. .P
  445. All type specifiers, except for
  446. .BR s ,
  447. can be followed by a mask specifier of the form &\fInumber\fP. The mask
  448. value shall be AND'ed with the value of the input file before the
  449. comparison with the
  450. .IR value
  451. field of the line is made. By default, the mask shall be interpreted as
  452. an unsigned decimal number. With a leading 0x or 0X, the mask shall be
  453. interpreted as an unsigned hexadecimal number; otherwise, with a
  454. leading 0, the mask shall be interpreted as an unsigned octal number.
  455. .P
  456. The strings
  457. .BR byte ,
  458. .BR short ,
  459. .BR long ,
  460. and
  461. .BR string
  462. shall also be supported as type fields, being interpreted as
  463. .BR dC ,
  464. .BR dS ,
  465. .BR dL ,
  466. and
  467. .BR s ,
  468. respectively.
  469. .RE
  470. .IP "\fIvalue\fP" 10
  471. The
  472. .IR value
  473. to be compared with the value from the file.
  474. .RS 10
  475. .P
  476. If the specifier from the type field is
  477. .BR s
  478. or
  479. .BR string ,
  480. then interpret the value as a string. Otherwise, interpret it as a
  481. number. If the value is a string, then the test shall succeed only when
  482. a string value exactly matches the bytes from the file.
  483. .P
  484. If the
  485. .IR value
  486. is a string, it can contain the following sequences:
  487. .IP "\e\fIcharacter\fR" 12
  488. The
  489. <backslash>-escape
  490. sequences as specified in the Base Definitions volume of POSIX.1\(hy2017,
  491. .IR "Table 5-1" ", " "Escape Sequences and Associated Actions"
  492. (\c
  493. .BR '\e\e' ,
  494. .BR '\ea' ,
  495. .BR '\eb' ,
  496. .BR '\ef' ,
  497. .BR '\en' ,
  498. .BR '\er' ,
  499. .BR '\et' ,
  500. .BR '\ev' ).
  501. In addition, the escape sequence
  502. .BR '\e\ '
  503. (the
  504. <backslash>
  505. character followed by a
  506. <space>
  507. character) shall be recognized to represent a
  508. <space>
  509. character. The results of using any other character, other than an
  510. octal digit, following the
  511. <backslash>
  512. are unspecified.
  513. .IP "\e\fIoctal\fR" 12
  514. Octal sequences that can be used to represent characters with specific
  515. coded values. An octal sequence shall consist of a
  516. <backslash>
  517. followed by the longest sequence of one, two, or three octal-digit
  518. characters (01234567).
  519. .P
  520. By default, any value that is not a string shall be interpreted as a
  521. signed decimal number. Any such value, with a leading 0x or 0X, shall
  522. be interpreted as an unsigned hexadecimal number; otherwise, with a
  523. leading zero, the value shall be interpreted as an unsigned octal
  524. number.
  525. .P
  526. If the value is not a string, it can be preceded by a character
  527. indicating the comparison to be performed. Permissible characters and
  528. the comparisons they specify are as follows:
  529. .IP "\fR=\fP" 6
  530. The test shall succeed if the value from the file equals the
  531. .IR value
  532. field.
  533. .IP "\fR<\fP" 6
  534. The test shall succeed if the value from the file is less than the
  535. .IR value
  536. field.
  537. .IP "\fR>\fP" 6
  538. The test shall succeed if the value from the file is greater than the
  539. .IR value
  540. field.
  541. .IP "\fR&\fP" 6
  542. The test shall succeed if all of the set bits in the
  543. .IR value
  544. field are set in the value from the file.
  545. .IP "\fR^\fP" 6
  546. The test shall succeed if at least one of the set bits in the
  547. .IR value
  548. field is not set in the value from the file.
  549. .IP "\fRx\fP" 6
  550. The test shall succeed if the file is large enough to contain a value
  551. of the type specified starting at the offset specified.
  552. .RE
  553. .IP "\fImessage\fP" 10
  554. The
  555. .IR message
  556. to be printed if the test succeeds. The
  557. .IR message
  558. shall be interpreted using the notation for the
  559. .IR printf
  560. formatting specification; see
  561. .IR printf .
  562. If the
  563. .IR value
  564. field was a string, then the value from the file shall be the argument
  565. for the
  566. .IR printf
  567. formatting specification; otherwise, the value from the file shall be
  568. the argument.
  569. .br
  570. .SH "EXIT STATUS"
  571. The following exit values shall be returned:
  572. .IP "\00" 6
  573. Successful completion.
  574. .IP >0 6
  575. An error occurred.
  576. .SH "CONSEQUENCES OF ERRORS"
  577. Default.
  578. .LP
  579. .IR "The following sections are informative."
  580. .SH "APPLICATION USAGE"
  581. The
  582. .IR file
  583. utility can only be required to guess at many of the file types because
  584. only exhaustive testing can determine some types with certainty. For
  585. example, binary data on some implementations might match the initial
  586. segment of an executable or a
  587. .IR tar
  588. archive.
  589. .P
  590. Note that the table indicates that the output contains the stated
  591. string. Systems may add text before or after the string. For
  592. executables, as an example, the machine architecture and various facts
  593. about how the file was link-edited may be included. Note also that on
  594. systems that recognize shell script files starting with
  595. .BR \(dq#!\(dq
  596. as executable files, these may be identified as executable binary files
  597. rather than as shell scripts.
  598. .SH EXAMPLES
  599. Determine whether an argument is a binary executable file:
  600. .sp
  601. .RS 4
  602. .nf
  603. file -- "$1" | grep -q \(aq:.*executable\(aq &&
  604. printf "%s is executable.\en$1"
  605. .fi
  606. .P
  607. .RE
  608. .SH RATIONALE
  609. The
  610. .BR \-f
  611. option was omitted because the same effect can (and should) be obtained
  612. using the
  613. .IR xargs
  614. utility.
  615. .P
  616. Historical versions of the
  617. .IR file
  618. utility attempt to identify the following types of files: symbolic
  619. link, directory, character special, block special, socket,
  620. .IR tar
  621. archive,
  622. .IR cpio
  623. archive, SCCS archive, archive library, empty,
  624. .IR compress
  625. output,
  626. .IR pack
  627. output, binary data, C source, FORTRAN source, assembler source,
  628. .IR nroff /\c
  629. .IR troff /\c
  630. .IR eqn /\c
  631. .IR tbl
  632. source
  633. .IR troff
  634. output, shell script, C shell script, English text, ASCII text, various
  635. executables, APL workspace, compiled terminfo entries, and CURSES
  636. screen images. Only those types that are reasonably well specified in
  637. POSIX or are directly related to POSIX utilities are listed in the
  638. table.
  639. .P
  640. Historical systems have used a ``magic file'' named
  641. .BR /etc/magic
  642. to help identify file types. Because it is generally useful for users
  643. and scripts to be able to identify special file types, the
  644. .BR \-m
  645. flag and a portable format for user-created magic files has been
  646. specified. No requirement is made that an implementation of
  647. .IR file
  648. use this method of identifying files, only that users be permitted to
  649. add their own classifying tests.
  650. .P
  651. In addition, three options have been added to historical practice. The
  652. .BR \-d
  653. flag has been added to permit users to cause their tests to follow any
  654. default system tests. The
  655. .BR \-i
  656. flag has been added to permit users to test portably for regular files
  657. in shell scripts. The
  658. .BR \-M
  659. flag has been added to permit users to ignore any default system
  660. tests.
  661. .P
  662. The POSIX.1\(hy2008 description of default system tests and the interaction
  663. between the
  664. .BR \-d ,
  665. .BR \-M ,
  666. and
  667. .BR \-m
  668. options did not clearly indicate that there were two types of ``default
  669. system tests''. The ``position-sensitive tests'' determine file types
  670. by looking for certain string or binary values at specific offsets in
  671. the file being examined. These position-sensitive tests were
  672. implemented in historical systems using the magic file described above.
  673. Some of these tests are now built into the
  674. .IR file
  675. utility itself on some implementations so the output can provide more
  676. detail than can be provided by magic files. For example, a magic file
  677. can easily identify a
  678. .BR core
  679. file on most implementations, but cannot name the program file that
  680. dropped the core. A magic file could produce output such as:
  681. .sp
  682. .RS 4
  683. .nf
  684. /home/dwc/core: ELF 32-bit MSB core file SPARC Version 1
  685. .fi
  686. .P
  687. .RE
  688. .P
  689. but by building the test into the
  690. .IR file
  691. utility, you could get output such as:
  692. .sp
  693. .RS 4
  694. .nf
  695. /home/dwc/core: ELF 32-bit MSB core file SPARC Version 1, from \(aqtestprog\(aq
  696. .fi
  697. .P
  698. .RE
  699. .P
  700. These extended built-in tests are still to be treated as
  701. position-sensitive default system tests even if they are not listed in
  702. .BR /etc/magic
  703. or any other magic file.
  704. .P
  705. The context-sensitive default system tests were always built into the
  706. .IR file
  707. utility. These tests looked for language constructs in text files
  708. trying to identify shell scripts, C, FORTRAN, and other computer
  709. language source files, and even plain text files. With the addition of
  710. the
  711. .BR \-m
  712. and
  713. .BR \-M
  714. options the distinction between position-sensitive and
  715. context-sensitive default system tests became important because the
  716. order of testing is important. The context-sensitive system default
  717. tests should never be applied before any position-sensitive tests even
  718. if the
  719. .BR \-d
  720. option is specified before a
  721. .BR \-m
  722. option or
  723. .BR \-M
  724. option due to the high probability that the context-sensitive system
  725. default tests will incorrectly identify arbitrary text files as text
  726. files before position-sensitive tests specified by the
  727. .BR \-m
  728. or
  729. .BR \-M
  730. option would be applied to give a more accurate identification.
  731. .P
  732. Leaving the meaning of
  733. .BR "\-M \-"
  734. and
  735. .BR "\-m \-"
  736. unspecified allows an existing prototype of these options to continue
  737. to work in a backwards-compatible manner. (In that implementation,
  738. .BR "\-M \-"
  739. was roughly equivalent to
  740. .BR \-d
  741. in POSIX.1\(hy2008.)
  742. .P
  743. The historical
  744. .BR \-c
  745. option was omitted as not particularly useful to users or portable
  746. shell scripts. In addition, a reasonable implementation of the
  747. .IR file
  748. utility would report any errors found each time the magic file is
  749. read.
  750. .P
  751. The historical format of the magic file was the same as that specified
  752. by the Rationale in the ISO\ POSIX\(hy2:\|1993 standard for the
  753. .IR offset ,
  754. .IR value ,
  755. and
  756. .IR message
  757. fields; however, it used less precise type fields than the format
  758. specified by the current normative text. The new type field values are
  759. a superset of the historical ones.
  760. .P
  761. The following is an example magic file:
  762. .sp
  763. .RS 4
  764. .nf
  765. 0 short 070707 cpio archive
  766. 0 short 0143561 Byte-swapped cpio archive
  767. 0 string 070707 ASCII cpio archive
  768. 0 long 0177555 Very old archive
  769. 0 short 0177545 Old archive
  770. 0 short 017437 Old packed data
  771. 0 string \e037\e036 Packed data
  772. 0 string \e377\e037 Compacted data
  773. 0 string \e037\e235 Compressed data
  774. >2 byte&0x80 >0 Block compressed
  775. >2 byte&0x1f x %d bits
  776. 0 string \e032\e001 Compiled Terminfo Entry
  777. 0 short 0433 Curses screen image
  778. 0 short 0434 Curses screen image
  779. 0 string <ar> System V Release 1 archive
  780. 0 string !<arch>\en__.SYMDEF Archive random library
  781. 0 string !<arch> Archive
  782. 0 string ARF_BEGARF PHIGS clear text archive
  783. 0 long 0x137A2950 Scalable OpenFont binary
  784. 0 long 0x137A2951 Encrypted scalable OpenFont binary
  785. .fi
  786. .P
  787. .RE
  788. .P
  789. The use of a basic integer data type is intended to allow the
  790. implementation to choose a word size commonly used by applications
  791. on that architecture.
  792. .P
  793. Earlier versions of this standard allowed for implementations with
  794. bytes other than eight bits, but this has been modified in this
  795. version.
  796. .SH "FUTURE DIRECTIONS"
  797. None.
  798. .SH "SEE ALSO"
  799. .IR "\fIar\fR\^",
  800. .IR "\fIls\fR\^",
  801. .IR "\fIpax\fR\^",
  802. .IR "\fIprintf\fR\^"
  803. .P
  804. The Base Definitions volume of POSIX.1\(hy2017,
  805. .IR "Table 5-1" ", " "Escape Sequences and Associated Actions",
  806. .IR "Chapter 8" ", " "Environment Variables",
  807. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  808. .\"
  809. .SH COPYRIGHT
  810. Portions of this text are reprinted and reproduced in electronic form
  811. from IEEE Std 1003.1-2017, Standard for Information Technology
  812. -- Portable Operating System Interface (POSIX), The Open Group Base
  813. Specifications Issue 7, 2018 Edition,
  814. Copyright (C) 2018 by the Institute of
  815. Electrical and Electronics Engineers, Inc and The Open Group.
  816. In the event of any discrepancy between this version and the original IEEE and
  817. The Open Group Standard, the original IEEE and The Open Group Standard
  818. is the referee document. The original Standard can be obtained online at
  819. http://www.opengroup.org/unix/online.html .
  820. .PP
  821. Any typographical or formatting errors that appear
  822. in this page are most likely
  823. to have been introduced during the conversion of the source files to
  824. man page format. To report such errors, see
  825. https://www.kernel.org/doc/man-pages/reporting_bugs.html .