logo

utils-std

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

cut.1 (1904B)


  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 September 12, 2024
  5. .Dt CUT 1
  6. .Os
  7. .Sh NAME
  8. .Nm cut
  9. .Nd cut each line with selected characters/fields
  10. .Sh SYNOPSIS
  11. .Nm
  12. .Fl b Ar list
  13. .Op Fl nuz
  14. .Op Ar file...
  15. .Nm
  16. .Fl c Ar list
  17. .Op Fl uz
  18. .Op Ar file...
  19. .Nm
  20. .Fl f Ar list
  21. .Op Fl d Ar delim
  22. .Op Fl suz
  23. .Op Ar file...
  24. .Sh DESCRIPTION
  25. .Nm
  26. reads lines from each each
  27. .Ar file
  28. or if unspecified standard input,
  29. and cuts out bytes
  30. .Pq Fl b ,
  31. characters
  32. .Pq Fl c ,
  33. or character-delimited fields
  34. .Pq Fl f .
  35. .Pp
  36. The
  37. .Ar list
  38. argument is a comma-separated list of 1-based ranges, where:
  39. .Bl -tag -width _1_2_3_
  40. .It Ql n-
  41. Selects from
  42. .Ql n
  43. to the end of line.
  44. .It Ql n
  45. Selects
  46. .Ql n
  47. .It Ql n-m
  48. Selects from
  49. .Ql n
  50. to
  51. .Ql m .
  52. .It Ql -m
  53. Selects from
  54. start of the line to
  55. .Ql m .
  56. .It Ql 1,2,3
  57. is equivalent to
  58. .Ql 1-3
  59. .El
  60. .Sh OPTIONS
  61. .Bl -tag -width _d_delim
  62. .It Fl b Ar list
  63. Cut bytes based on
  64. .Ar list .
  65. .It Fl c Ar list
  66. Cut codepoints based on
  67. .Ar list .
  68. .It Fl d Ar delim
  69. Set the field delimiter to the character
  70. .Ar delim ,
  71. if an empty string is passed, then NULL is used as separator.
  72. (default:\ \et)
  73. .It Fl f Ar list
  74. Cut fields based on
  75. .Ar list .
  76. .It Fl n
  77. Prevent splitting codepoints.
  78. If the last byte of a codepoint is part of the selection, it gets printed, otherwise it gets dropped.
  79. .It Fl s
  80. Suppress lines with no delimiter characters,
  81. otherwise whole delimiter-less lines are printed as-is.
  82. .It Fl u
  83. Switch to line-buffering, instead of full-buffering when non-interactive.
  84. .It Fl z
  85. Use NULL as line separator instead of newline.
  86. .El
  87. .Sh EXIT STATUS
  88. .Ex -std
  89. .Sh STANDARDS
  90. .Nm
  91. should be compliant with the
  92. IEEE Std 1003.1-2024 (“POSIX.1”)
  93. specification.
  94. .Pp
  95. The
  96. .Fl u
  97. option is an utils-std extension.
  98. .Sh AUTHORS
  99. .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me