logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

head.1 (1960B)


  1. .\" utils-std: Collection of commonly available Unix tools
  2. .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. .\" SPDX-License-Identifier: MPL-2.0
  4. .Dd June 29, 2025
  5. .Dt HEAD 1
  6. .Os
  7. .Sh NAME
  8. .Nm head
  9. .Nd print first part of files
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Op Fl qvz
  13. .Op Fl c Ar size | Fl n Oo Ar - Oc Ns Ar num | Fl Ar num
  14. .Op Ar file...
  15. .Sh DESCRIPTION
  16. .Nm
  17. reads each
  18. .Ar file
  19. in sequence and writes it's first part on standard output.
  20. If no
  21. .Ar file
  22. is given,
  23. .Nm
  24. reads from the standard input.
  25. .Sh OPTIONS
  26. .Bl -tag -width _c_size
  27. .It Fl c Ar size
  28. Read the first
  29. .Ar size
  30. bytes
  31. in each
  32. .Ar file .
  33. .Pp
  34. .Ar size
  35. can be multiplied by one of KMGTP (Kilo, Mega, Giga, Tera, ...)
  36. using power of 1024 by default, which can be either explicit via adding iB
  37. (like MiB), or turned into powers of 1000 by adding B (like MB).
  38. .It Fl n Oo Ar - Oc Ns Ar num , Fl Ar num
  39. Read the first
  40. .Ar num
  41. lines in each
  42. .Ar file .
  43. .Pp
  44. If
  45. .Ar num
  46. is negative, then it is relative to end-of-file, for example
  47. .Cm head
  48. .Fl n
  49. .Ar -2
  50. will omit the last 2 lines.
  51. .Pp
  52. The
  53. .Fl Ar num
  54. form is historical, new scripts should use the standard
  55. .Fl n Ar num
  56. form.
  57. .It Fl q
  58. Don't print header when multiple
  59. .Ar file
  60. are given.
  61. .It Fl v
  62. Always print header, regardless of the number of given
  63. .Ar file .
  64. .It Fl z
  65. Use NULL as line delimiter, not newline.
  66. .El
  67. .Pp
  68. If no option is specified,
  69. .Nm
  70. defaults to reading the first 10 lines.
  71. .Sh EXIT STATUS
  72. .Ex -std
  73. .Sh STDOUT
  74. Contains the specified part of each
  75. .Ar file ,
  76. with the following header when multiple
  77. .Ar file
  78. are given, or when
  79. .Fl v
  80. is set:
  81. .Bd -literal
  82. "==> %s <==\\n", <file>
  83. .Ed
  84. .Sh STANDARDS
  85. .Nm
  86. should be compliant with the
  87. IEEE Std 1003.1-2024 (“POSIX.1”)
  88. specification.
  89. .Pp
  90. The
  91. .Fl q ,
  92. .Fl v ,
  93. and
  94. .Fl z
  95. options are extensions.
  96. Negative values in option
  97. .Fl n
  98. is a extension inspired by GNU coreutils.
  99. .br
  100. The
  101. .Fl Ar num
  102. option is historical.
  103. .Sh AUTHORS
  104. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me