Linux常用基本命令(split )
Posted ghostwu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux常用基本命令(split )相关的知识,希望对你有一定的参考价值。
split命令
作用:切割文件
格式:
split [option] [input] [prefix]
-l 指定分割后文件的最大行数
[email protected]:~/linux/split$ cat -n ghostwu.txt 1 What is Memcached? 2 Free & open source, 3 high-performance, 4 distributed memory object caching system, 5 generic in nature 6 but intended for use in speeding up dynamic web applications by alleviating database load. 7 Memcached is an in-memory key-value store for small chunks of arbitrary data 8 (strings, objects) from results of database calls 9 API calls, or page rendering. 10 Memcached is simple yet powerful. 11 Its simple design promotes quick deployment, 12 ease of development 13 and solves many problems facing large data caches. 14 Its API is available for most popular languages.
把ghostwu.txt这个文件,每个文件最大6行,前缀为ghostwu_
[email protected]:~/linux/split$ ls ghostwu.txt [email protected]:~/linux/split$ wc -l ghostwu.txt 14 ghostwu.txt [email protected]:~/linux/split$ split -l 6 ghostwu.txt ghostwu_ [email protected]:~/linux/split$ ls ghostwu_aa ghostwu_ab ghostwu_ac ghostwu.txt [email protected]:~/linux/split$ wc -l ghostwu_ab 6 ghostwu_ab [email protected]:~/linux/split$ wc -l ghostwu_aa 6 ghostwu_aa [email protected]:~/linux/split$ wc -l ghostwu_ac 2 ghostwu_ac
用通配符更简单
[email protected]:~/linux/split$ ls ghostwu_aa ghostwu_ab ghostwu_ac ghostwu.txt [email protected]:~/linux/split$ wc -l ghostwu_* 6 ghostwu_aa 6 ghostwu_ab 2 ghostwu_ac 14 total
-a : 指定切割文件的后缀长度
[email protected]:~/linux/split$ split -l 5 -a 3 ghostwu.txt ghostwu_ [email protected]:~/linux/split$ ls ghostwu_aaa ghostwu_aab ghostwu_aac ghostwu.txt [email protected]:~/linux/split$ wc -l ghostwu_* 5 ghostwu_aaa 5 ghostwu_aab 4 ghostwu_aac 14 total
-d: 使用数字后缀
[email protected]:~/linux/split$ ls ghostwu.txt [email protected]:~/linux/split$ split -l 5 -d ghostwu.txt ghostwu_ [email protected]:~/linux/split$ ls ghostwu_00 ghostwu_01 ghostwu_02 ghostwu.txt [email protected]:~/linux/split$ wc -l ghostwu_* 5 ghostwu_00 5 ghostwu_01 4 ghostwu_02 14 total
-b 按文件大小
[email protected]:~/linux/split$ ls ghostwu.txt [email protected]:~/linux/split$ ls -lh total 4.0K -rw-rw-r-- 1 ghostwu ghostwu 565 5月 20 18:41 ghostwu.txt [email protected]:~/linux/split$ split -b 100 ghostwu.txt ghostwu_ [email protected]:~/linux/split$ ls ghostwu_aa ghostwu_ac ghostwu_ae ghostwu.txt ghostwu_ab ghostwu_ad ghostwu_af [email protected]:~/linux/split$ ls -lh total 28K -rw-rw-r-- 1 ghostwu ghostwu 100 5月 20 18:54 ghostwu_aa -rw-rw-r-- 1 ghostwu ghostwu 100 5月 20 18:54 ghostwu_ab -rw-rw-r-- 1 ghostwu ghostwu 100 5月 20 18:54 ghostwu_ac -rw-rw-r-- 1 ghostwu ghostwu 100 5月 20 18:54 ghostwu_ad -rw-rw-r-- 1 ghostwu ghostwu 100 5月 20 18:54 ghostwu_ae -rw-rw-r-- 1 ghostwu ghostwu 65 5月 20 18:54 ghostwu_af -rw-rw-r-- 1 ghostwu ghostwu 565 5月 20 18:41 ghostwu.txt
以上是关于Linux常用基本命令(split )的主要内容,如果未能解决你的问题,请参考以下文章