Linux command
split 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Split file into 1000-line pieces
split [file]
Split into pieces with custom prefix
split [file] [prefix_]
Split into specific number of lines
split -l [500] [file]
Split into specific size pieces
split -b [10M] [file]
Split into N equal pieces
split -n [5] [file]
Split with numeric suffixes
split -d [file]
Split with custom suffix length
split -a [4] [file]
说明
split divides a file into smaller pieces. By default, it creates files with 1000 lines each, named with a prefix (default: x) followed by a suffix (aa, ab, ac, ...). The command is useful for breaking large files for transmission, processing, or storage limitations. It works with both text and binary files. Size specifications accept suffixes: K (kilobytes), M (megabytes), G (gigabytes), and also KB, MB, GB for powers of 1000. Split reads from stdin if no file is specified or if file is -.
参数
- -l _lines_, --lines=_lines_
- Put specified number of lines per output file
- -b _size_, --bytes=_size_
- Put specified bytes per output file (K, M, G suffixes)
- -n _chunks_, --number=_chunks_
- Generate specified number of output files
- -d, --numeric-suffixes
- Use numeric suffixes instead of alphabetic
- -a _N_, --suffix-length=_N_
- Generate suffixes of length N (default: 2)
- -e, --elide-empty-files
- Do not generate empty output files with -n
- --verbose
- Print message for each output file
- --additional-suffix=_suf_
- Append additional suffix to file names
- -x, --hex-suffixes
- Use hexadecimal suffixes
FAQ
What is the split command used for?
split divides a file into smaller pieces. By default, it creates files with 1000 lines each, named with a prefix (default: x) followed by a suffix (aa, ab, ac, ...). The command is useful for breaking large files for transmission, processing, or storage limitations. It works with both text and binary files. Size specifications accept suffixes: K (kilobytes), M (megabytes), G (gigabytes), and also KB, MB, GB for powers of 1000. Split reads from stdin if no file is specified or if file is -.
How do I run a basic split example?
Run `split [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -l _lines_, --lines=_lines_ do in split?
Put specified number of lines per output file