Linux command
csplit 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Example
csplit [path/to/file] 10
Example
csplit [path/to/file] 7 23
Example
csplit [path/to/file] 5 {*}
Example
csplit -k [path/to/file] 5 {*}
Example
csplit [path/to/file] 5 -f [prefix]
Example
csplit [path/to/file] /[regex]/
说明
csplit splits a file into pieces based on context (line numbers or patterns). It generates files named xx00, xx01, etc. by default. Unlike split which divides by size, csplit divides by content structure, making it useful for splitting log files, configuration files, or documents at specific boundaries.
参数
- -f, --prefix _prefix_
- Use specified prefix instead of 'xx'
- -k, --keep-files
- Don't remove output files on error
- -n, --digits _digits_
- Number of digits in output filename
- -s, --quiet
- Don't print byte counts
- {n}
- Repeat previous pattern n times
- **{*}**
- Repeat previous pattern as many times as possible
FAQ
What is the csplit command used for?
csplit splits a file into pieces based on context (line numbers or patterns). It generates files named xx00, xx01, etc. by default. Unlike split which divides by size, csplit divides by content structure, making it useful for splitting log files, configuration files, or documents at specific boundaries.
How do I run a basic csplit example?
Run `csplit [path/to/file] 10` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f, --prefix _prefix_ do in csplit?
Use specified prefix instead of 'xx'