《Linux就该这么学》是一本基于最新Linux系统编写的入门必读书籍,内容面向零基础读者,由浅入深渐进式教学,销量保持国内第一,年销售量预期超过10万本。点此免费在线阅读。
[root@roclinux ~]$ dd if=/dev/zero bs=1024 count=700000 of=king_of_ring.avi 700000+0 records in 700000+0 records out 716800000 bytes (717 MB) copied, 12.9189 s, 55.5 MB/s [root@roclinux ~]$ ls -l king_of_ring.avi -rw-r--r-- 1 root root 716800000 Apr 12 13:01 king_of_ring.avi
-b
选项,来指定每个拆分文件的大小:
[root@roclinux ~]$ split -b 400M king_of_ring.avi [root@roclinux ~]$ ls -l total 1400008 -rw-r--r-- 1 root root 716800000 Apr 12 13:01 king_of_ring.avi -rw-r--r-- 1 root root 419430400 Apr 12 13:04 xaa -rw-r--r-- 1 root root 297369600 Apr 12 13:04 xab
split [-b ][-C ][-][-l ][要切割的文件][输出文件名前缀][-a ]
[root@roclinux ~]$ cat xaa xab > king_of_ring_merge.avi [root@roclinux ~]$ ls -l total 2100012 -rw-r--r-- 1 root root 716800000 Apr 12 13:01 king_of_ring.avi -rw-r--r-- 1 root root 716800000 Apr 12 13:07 king_of_ring_merge.avi -rw-r--r-- 1 root root 419430400 Apr 12 13:04 xaa -rw-r--r-- 1 root root 297369600 Apr 12 13:04 xab
copy /b xaa + xab king_of_ring.avi
#我们指定了king_of_ring_part_前缀 [root@roclinux ~]$ split -b 400m king_of_ring.avi king_of_ring_part_ #可以看到, 文件名的可读性提高了很多 [root@roclinux ~]$ ls -l king* -rw-r--r-- 1 root root 716800000 Feb 25 18:29 king_of_ring.avi -rw-r--r-- 1 root root 419430400 Feb 25 19:24 king_of_ring_part_aa -rw-r--r-- 1 root root 297369600 Feb 25 19:24 king_of_ring_part_ab
#使用了-d选项 [root@roclinux ~]$ split -b 400m -d king_of_ring.avi king_of_ring_part_ #后缀从原来的aa、ab变成了00、01 [root@roclinux ~]$ ls -l king* -rw-r--r-- 1 root root 716800000 Feb 25 18:29 king_of_ring.avi -rw-r--r-- 1 root root 419430400 Feb 25 19:24 king_of_ring_part_00 -rw-r--r-- 1 root root 297369600 Feb 25 19:24 king_of_ring_part_01
#使用-N来指定拆分的行数,本例中为-10 [root@roclinux ~]$ split -d -10 /etc/passwd my_passwd_ #可以看到拆分成功 [root@roclinux ~]$ wc -l my_passwd_* 10 my_passwd_00 10 my_passwd_01 5 my_passwd_02 25 total
#对原先的文件计算md5值 [root@roclinux ~]$ md5sum king_of_ring.avi eacff27bf2db99c7301383b7d8c1c07c king_of_ring.avi #对合并后的文件计算md5值, 并与原值进行比较 [root@roclinux ~]$ md5sum king_of_ring_merge.avi eacff27bf2db99c7301383b7d8c1c07c king_of_ring_merge.avi如果前后一致,那么恭喜你,文件合并成功!
split命令_Linux split命令:切割(拆分)文件
原文:https://www.cnblogs.com/seasonzone/p/14419415.html