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

csplit.1p (8911B)


  1. '\" et
  2. .TH CSPLIT "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. csplit
  12. \(em split files based on context
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. csplit \fB[\fR-ks\fB] [\fR-f \fIprefix\fB] [\fR-n \fInumber\fB] \fIfile arg\fR...
  17. .fi
  18. .SH DESCRIPTION
  19. The
  20. .IR csplit
  21. utility shall read the file named by the
  22. .IR file
  23. operand, write all or part of that file into other files as directed
  24. by the
  25. .IR arg
  26. operands, and write the sizes of the files.
  27. .SH OPTIONS
  28. The
  29. .IR csplit
  30. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  31. .IR "Section 12.2" ", " "Utility Syntax Guidelines".
  32. .P
  33. The following options shall be supported:
  34. .IP "\fB\-f\ \fIprefix\fR" 10
  35. Name the created files
  36. .IR prefix \c
  37. .BR 00 ,
  38. .IR prefix \c
  39. .BR 01 ,
  40. \&.\|.\|.,
  41. .IR prefixn .
  42. The default is
  43. .BR xx00
  44. \&.\|.\|.
  45. .BR xx \c
  46. .IR n .
  47. If the
  48. .IR prefix
  49. argument would create a filename exceeding
  50. {NAME_MAX}
  51. bytes, an error shall result,
  52. .IR csplit
  53. shall exit with a diagnostic message, and no files shall be created.
  54. .IP "\fB\-k\fP" 10
  55. Leave previously created files intact. By default,
  56. .IR csplit
  57. shall remove created files if an error occurs.
  58. .IP "\fB\-n\ \fInumber\fR" 10
  59. Use
  60. .IR number
  61. decimal digits to form filenames for the file pieces. The default
  62. shall be 2.
  63. .IP "\fB\-s\fP" 10
  64. Suppress the output of file size messages.
  65. .SH OPERANDS
  66. The following operands shall be supported:
  67. .IP "\fIfile\fR" 10
  68. The pathname of a text file to be split. If
  69. .IR file
  70. is
  71. .BR '\-' ,
  72. the standard input shall be used.
  73. .P
  74. Each
  75. .IR arg
  76. operand can be one of the following:
  77. .IP "/\fIrexp\fR/\fB[\fIoffset\fB]\fR" 10
  78. .br
  79. A file shall be created using the content of the lines from the current
  80. line up to, but not including, the line that results from the
  81. evaluation of the regular expression with
  82. .IR offset ,
  83. if any, applied. The regular expression
  84. .IR rexp
  85. shall follow the rules for basic regular expressions described in the Base Definitions volume of POSIX.1\(hy2017,
  86. .IR "Section 9.3" ", " "Basic Regular Expressions".
  87. The application shall use the sequence
  88. .BR \(dq\e/\(dq
  89. to specify a
  90. <slash>
  91. character within the
  92. .IR rexp .
  93. The optional offset shall be a positive or negative integer value
  94. representing a number of lines. A positive integer value can be
  95. preceded by
  96. .BR '\(pl' .
  97. If the selection of lines from an
  98. .IR offset
  99. expression of this type would create a file with zero lines, or one
  100. with greater than the number of lines left in the input file, the
  101. results are unspecified. After the section is created, the current line
  102. shall be set to the line that results from the evaluation of the
  103. regular expression with any offset applied. If the current line is the
  104. first line in the file and a regular expression operation has not yet
  105. been performed, the pattern match of
  106. .IR rexp
  107. shall be applied from the current line to the end of the file.
  108. Otherwise, the pattern match of
  109. .IR rexp
  110. shall be applied from the line following the current line to the end of
  111. the file.
  112. .IP "%\fIrexp\fR%\fB[\fIoffset\fB]\fR" 10
  113. .br
  114. Equivalent to /\fIrexp\fR/\fB[\fIoffset\fB]\fR, except that no
  115. file shall be created for the selected section of the input file. The
  116. application shall use the sequence
  117. .BR \(dq\e%\(dq
  118. to specify a
  119. <percent-sign>
  120. character within the
  121. .IR rexp .
  122. .IP "\fIline_no\fR" 10
  123. Create a file from the current line up to (but not including) the line
  124. number
  125. .IR line_no .
  126. Lines in the file shall be numbered starting at one. The current line
  127. becomes
  128. .IR line_no .
  129. .IP "{\fInum\fR}" 10
  130. Repeat operand. This operand can follow any of the operands described
  131. previously. If it follows a
  132. .IR rexp
  133. type operand, that operand shall be applied
  134. .IR num
  135. more times. If it follows a
  136. .IR line_no
  137. operand, the file shall be split every
  138. .IR line_no
  139. lines,
  140. .IR num
  141. times, from that point.
  142. .P
  143. An error shall be reported if an operand does not reference a line
  144. between the current position and the end of the file.
  145. .SH STDIN
  146. See the INPUT FILES section.
  147. .SH "INPUT FILES"
  148. The input file shall be a text file.
  149. .SH "ENVIRONMENT VARIABLES"
  150. The following environment variables shall affect the execution of
  151. .IR csplit :
  152. .IP "\fILANG\fP" 10
  153. Provide a default value for the internationalization variables that are
  154. unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
  155. .IR "Section 8.2" ", " "Internationalization Variables"
  156. for the precedence of internationalization variables used to determine
  157. the values of locale categories.)
  158. .IP "\fILC_ALL\fP" 10
  159. If set to a non-empty string value, override the values of all the
  160. other internationalization variables.
  161. .IP "\fILC_COLLATE\fP" 10
  162. .br
  163. Determine the locale for the behavior of ranges, equivalence classes,
  164. and multi-character collating elements within regular expressions.
  165. .IP "\fILC_CTYPE\fP" 10
  166. Determine the locale for the interpretation of sequences of bytes of
  167. text data as characters (for example, single-byte as opposed to
  168. multi-byte characters in arguments and input files) and the behavior of
  169. character classes within regular expressions.
  170. .IP "\fILC_MESSAGES\fP" 10
  171. .br
  172. Determine the locale that should be used to affect the format and
  173. contents of diagnostic messages written to standard error.
  174. .IP "\fINLSPATH\fP" 10
  175. Determine the location of message catalogs for the processing of
  176. .IR LC_MESSAGES .
  177. .SH "ASYNCHRONOUS EVENTS"
  178. If the
  179. .BR \-k
  180. option is specified, created files shall be retained. Otherwise, the
  181. default action occurs.
  182. .SH STDOUT
  183. Unless the
  184. .BR \-s
  185. option is used, the standard output shall consist of one line per
  186. file created, with a format as follows:
  187. .sp
  188. .RS 4
  189. .nf
  190. "%d\en", <\fIfile size in bytes\fR>
  191. .fi
  192. .P
  193. .RE
  194. .SH STDERR
  195. The standard error shall be used only for diagnostic messages.
  196. .SH "OUTPUT FILES"
  197. The output files shall contain portions of the original input file;
  198. otherwise, unchanged.
  199. .SH "EXTENDED DESCRIPTION"
  200. None.
  201. .SH "EXIT STATUS"
  202. The following exit values shall be returned:
  203. .IP "\00" 6
  204. Successful completion.
  205. .IP >0 6
  206. An error occurred.
  207. .SH "CONSEQUENCES OF ERRORS"
  208. By default, created files shall be removed if an error occurs. When the
  209. .BR \-k
  210. option is specified, created files shall not be removed if an error
  211. occurs.
  212. .LP
  213. .IR "The following sections are informative."
  214. .SH "APPLICATION USAGE"
  215. None.
  216. .SH EXAMPLES
  217. .IP " 1." 4
  218. This example creates four files,
  219. .BR cobol00
  220. \&.\|.\|.
  221. .BR cobol03 :
  222. .RS 4
  223. .sp
  224. .RS 4
  225. .nf
  226. csplit -f cobol file \(aq/procedure division/\(aq /par5./ /par16./
  227. .fi
  228. .P
  229. .RE
  230. .P
  231. After editing the split files, they can be recombined as follows:
  232. .sp
  233. .RS 4
  234. .nf
  235. cat cobol0[0-3] > file
  236. .fi
  237. .P
  238. .RE
  239. .P
  240. Note that this example overwrites the original file.
  241. .RE
  242. .IP " 2." 4
  243. This example would split the file after the first 99 lines, and every
  244. 100 lines thereafter, up to 9\|999 lines; this is because lines in the
  245. file are numbered from 1 rather than zero, for historical reasons:
  246. .RS 4
  247. .sp
  248. .RS 4
  249. .nf
  250. csplit -k file 100 {99}
  251. .fi
  252. .P
  253. .RE
  254. .RE
  255. .IP " 3." 4
  256. Assuming that
  257. .BR prog.c
  258. follows the C-language coding convention of ending routines with a
  259. .BR '}'
  260. at the beginning of the line, this example creates a file containing
  261. each separate C routine (up to 21) in
  262. .BR prog.c :
  263. .RS 4
  264. .sp
  265. .RS 4
  266. .nf
  267. csplit -k prog.c \(aq%main(%\(aq \(aq/\(ha}/+1\(aq {20}
  268. .fi
  269. .P
  270. .RE
  271. .RE
  272. .SH RATIONALE
  273. The
  274. .BR \-n
  275. option was added to extend the range of filenames that could be
  276. handled.
  277. .P
  278. Consideration was given to adding a
  279. .BR \-a
  280. flag to use the alphabetic filename generation used by the historical
  281. .IR split
  282. utility, but the functionality added by the
  283. .BR \-n
  284. option was deemed to make alphabetic naming unnecessary.
  285. .SH "FUTURE DIRECTIONS"
  286. None.
  287. .SH "SEE ALSO"
  288. .IR "\fIsed\fR\^",
  289. .IR "\fIsplit\fR\^"
  290. .P
  291. The Base Definitions volume of POSIX.1\(hy2017,
  292. .IR "Chapter 8" ", " "Environment Variables",
  293. .IR "Section 9.3" ", " "Basic Regular Expressions",
  294. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  295. .\"
  296. .SH COPYRIGHT
  297. Portions of this text are reprinted and reproduced in electronic form
  298. from IEEE Std 1003.1-2017, Standard for Information Technology
  299. -- Portable Operating System Interface (POSIX), The Open Group Base
  300. Specifications Issue 7, 2018 Edition,
  301. Copyright (C) 2018 by the Institute of
  302. Electrical and Electronics Engineers, Inc and The Open Group.
  303. In the event of any discrepancy between this version and the original IEEE and
  304. The Open Group Standard, the original IEEE and The Open Group Standard
  305. is the referee document. The original Standard can be obtained online at
  306. http://www.opengroup.org/unix/online.html .
  307. .PP
  308. Any typographical or formatting errors that appear
  309. in this page are most likely
  310. to have been introduced during the conversion of the source files to
  311. man page format. To report such errors, see
  312. https://www.kernel.org/doc/man-pages/reporting_bugs.html .