在linux系统中对文件进行分割

经常对从数据库中SPOOL出来的数据进行分割,而以往都是要在UltraEdit中一点点的剪切、复制,一直觉得linux中应该有个命令,今天终于找到了,那就是SPLIT。

[@more@]

下面是帮助信息:

[root@logana opt]# split --help
Usage: split [OPTION] [INPUT [PREFIX]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
PREFIX is `x'. With no INPUT, or when INPUT is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
-a, --suffix-length=N use suffixes of length N (default 2)
-b, --bytes=SIZE put SIZE bytes per output file
-C, --line-bytes=SIZE put at most SIZE bytes of lines per output file
-l, --lines=NUMBER put NUMBER lines per output file
--verbose print a diagnostic to standard error just
before each output file is opened
--help display this help and exit
--version output version information and exit

SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.

使用起来也非常简单,比如:

split -l 100000 xxx.lst aaaa

表示把xxx.lst分割成每10万行一个的文件,分割后的文件使用aaaa作为前缀

使用不同的参数,也可以按照文件的大小进行分割。

请使用浏览器的分享功能分享到微信等