split命令
作用:切割文件
格式:
split [option] [input] [prefix]
-l 指定分割后文件的最大行数
ghostwu@dev:~/linux/split$ cat -n ghostwu.txt
What is Memcached?
Free & open source,
high-performance,
distributed memory object caching system,
generic in nature
but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data
(strings, objects) from results of database calls
API calls, or page rendering.
Memcached is simple yet powerful.
Its simple design promotes quick deployment,
ease of development
and solves many problems facing large data caches.
Its API is available for most popular languages.
把ghostwu.txt这个文件,每个文件最大6行,前缀为ghostwu_
ghostwu@dev:~/linux/split$ ls
ghostwu.txt
ghostwu@dev:~/linux/split$ wc -l ghostwu.txt
ghostwu.txt
ghostwu@dev:~/linux/split$ split -l ghostwu.txt ghostwu_
ghostwu@dev:~/linux/split$ ls
ghostwu_aa ghostwu_ab ghostwu_ac ghostwu.txt
ghostwu@dev:~/linux/split$ wc -l ghostwu_ab
ghostwu_ab
ghostwu@dev:~/linux/split$ wc -l ghostwu_aa
ghostwu_aa
ghostwu@dev:~/linux/split$ wc -l ghostwu_ac
ghostwu_ac
用通配符更简单
ghostwu@dev:~/linux/split$ ls
ghostwu_aa ghostwu_ab ghostwu_ac ghostwu.txt
ghostwu@dev:~/linux/split$ wc -l ghostwu_*
ghostwu_aa
ghostwu_ab
ghostwu_ac
total
-a : 指定切割文件的后缀长度
ghostwu@dev:~/linux/split$ split -l -a ghostwu.txt ghostwu_
ghostwu@dev:~/linux/split$ ls
ghostwu_aaa ghostwu_aab ghostwu_aac ghostwu.txt
ghostwu@dev:~/linux/split$ wc -l ghostwu_*
ghostwu_aaa
ghostwu_aab
ghostwu_aac
total
-d: 使用数字后缀
ghostwu@dev:~/linux/split$ ls
ghostwu.txt
ghostwu@dev:~/linux/split$ split -l -d ghostwu.txt ghostwu_
ghostwu@dev:~/linux/split$ ls
ghostwu_00 ghostwu_01 ghostwu_02 ghostwu.txt
ghostwu@dev:~/linux/split$ wc -l ghostwu_*
ghostwu_00
ghostwu_01
ghostwu_02
total
-b 按文件大小
ghostwu@dev:~/linux/split$ ls
ghostwu.txt
ghostwu@dev:~/linux/split$ ls -lh
total .0K
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu.txt
ghostwu@dev:~/linux/split$ split -b ghostwu.txt ghostwu_
ghostwu@dev:~/linux/split$ ls
ghostwu_aa ghostwu_ac ghostwu_ae ghostwu.txt
ghostwu_ab ghostwu_ad ghostwu_af
ghostwu@dev:~/linux/split$ ls -lh
total 28K
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_aa
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_ab
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_ac
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_ad
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_ae
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu_af
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu.txt