简介
linux下的命令 dd、split 用于分割文件
cat命令用于合并文件
windows下使用 copy合并文件
linux下dd、split演示
测试文件 testfile 大小为 1004k
使用 split 命令将其 每600k切为一个文件
然后使用cat命令合并
使用 dd 命令将其 前700k复制为一个文件
剩余部分为一个复制为一个文件
然后使用cat命令合并
最后使用 sha1sum 验证文件是否相同
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
root@sharezx:/mnt# cp /bin/bash testfile
root@sharezx:/mnt# du -k testfile
1004 testfile
root@sharezx:/mnt# split -b 600k testfile sp_
root@sharezx:/mnt# du -k sp_*
600 sp_aa
404 sp_ab
root@sharezx:/mnt# cat sp_aa sp_ab > new-tf-sp
root@sharezx:/mnt#
root@sharezx:/mnt# dd if=testfile of=dd-sp-01 bs=350k count=2
2+0 records in
2+0 records out
716800 bytes (717 kB) copied, 0.00124676 s, 575 MB/s
root@sharezx:/mnt# dd if=testfile of=dd-sp-02 bs=350k skip=2
0+1 records in
0+1 records out
308056 bytes (308 kB) copied, 0.00061842 s, 498 MB/s
root@sharezx:/mnt# du -k dd-sp-*
700 dd-sp-01
304 dd-sp-02
root@sharezx:/mnt# cat dd-sp-* > new-tf-dd
root@sharezx:/mnt# sha1sum testfile new-tf-*
f841a2d1f609137788094b7c9f1441a30acb06f6 testfile
f841a2d1f609137788094b7c9f1441a30acb06f6 new-tf-dd
f841a2d1f609137788094b7c9f1441a30acb06f6 new-tf-sp
|
命令整理
文件大小的单位
K,M,G,T(以1024换算)
或KB,MB,GB(以1000换算)等
命令中都是用k为计数单位 注意不要加上b
1
2
3
4
5
6
7
8
9
10
11
12
13
|
cp /bin/bash testfile
du -k testfile
split -b 600k testfile sp_
du -k sp_*
cat sp_aa sp_ab > new-tf-sp
dd if=testfile of=dd-sp-01 bs=350k count=2
dd if=testfile of=dd-sp-02 bs=350k skip=2
du -k dd-sp-*
cat dd-sp-* > new-tf-dd
sha1sum testfile new-tf-*
|
命令说明
windows下合并文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
mnd@DESKTOP-1AC542D MINGW32 /e/myprogram/my_workspace/code_rep12/gos (master)
$ du -k wtestfile
1028 wtestfile
mnd@DESKTOP-1AC542D MINGW32 /e/myprogram/my_workspace/code_rep12/gos (master)
$ split.exe -d -b 400k wtestfile wsp_
mnd@DESKTOP-1AC542D MINGW32 /e/myprogram/my_workspace/code_rep12/gos (master)
$ du -k wsp_*
400 wsp_00
400 wsp_01
228 wsp_02
mnd@DESKTOP-1AC542D MINGW32 /e/myprogram/my_workspace/code_rep12/gos (master)
$ cmd
Microsoft Windows [版本 10.0.18362.267]
(c) 2019 Microsoft Corporation。保留所有权利。
E:\myprogram\my_workspace\code_rep12\gos>copy /b wsp_00 + wsp_01 + wsp_02 new-a
copy /b wsp_00 + wsp_01 + wsp_02 new-a
wsp_00
wsp_01
wsp_02
已复制 1 个文件。
E:\myprogram\my_workspace\code_rep12\gos>copy /b wsp_* new-b
copy /b wsp_* new-b
wsp_00
wsp_01
wsp_02
已复制 1 个文件。
E:\myprogram\my_workspace\code_rep12\gos>exit
exit
mnd@DESKTOP-1AC542D MINGW32 /e/myprogram/my_workspace/code_rep12/gos (master)
$ sha1sum.exe wtestfile new-*
fa0536e5b72c534ce6989070782fa9052cf4232b *wtestfile
fa0536e5b72c534ce6989070782fa9052cf4232b *new-a
fa0536e5b72c534ce6989070782fa9052cf4232b *new-b
|
命令整理
1
2
3
4
5
6
|
du -k wtestfile
split.exe -d -b 400k wtestfile wsp_
du -k wsp_*
copy /b wsp_00 + wsp_01 + wsp_02 new-a
copy /b wsp_* new-b
|
文章作者
duansheli
上次更新
2019-12-25
(325c7b3)