csplit
Quick Reference
Command Name:
csplit
Category:
file processing
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Log file processing
Split large log files into sections by date or event markers
- 2
Content extraction
Extract specific sections from structured documents
- 3
Data processing
Break large data files into manageable chunks for processing
- 4
Document segmentation
Divide documents by chapters, sections, or other logical units
Syntax
csplit [OPTION]... FILE PATTERN...
Options
Option | Description |
---|---|
-f, --prefix=PREFIX |
Use PREFIX instead of 'xx' for output files |
-b, --suffix-format=FORMAT |
Use sprintf FORMAT instead of '%02d' for output file names |
-n, --digits=DIGITS |
Use specified number of digits instead of 2 |
-k, --keep-files |
Do not remove output files on errors |
-s, --quiet, --silent |
Do not print counts of output file sizes |
-z, --elide-empty-files |
Remove empty output files |
--suppress-matched |
Suppress the lines matching PATTERN |
-F, --filter=SCRIPT |
Write to shell SCRIPT; filenames are $FILE variables |
--help |
Display help and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the csplit
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Split a file at line 100 csplit large_file.txt 100
Advanced Examples:
# Split a file at every occurrence of "CHAPTER" after line 10 csplit book.txt 10 '/CHAPTER/' '{*}'