Linux快速生成指定大小文件

使用dd命令

[root@centos7-18 ~]# dd if=/dev/zero of=test bs=1M count=2
2+0 records in
2+0 records out
2097152 bytes (2.1 MB) copied, 0.0075806 s, 277 MB/s
[root@centos7-18 ~]# ll -h test
-rw-r--r--. 1 root root 2.0M Jul 12 18:00 test

在这里插入图片描述

使用head命令

[root@centos7-18 ~]# head -c 1000000 /dev/zero > test
[root@centos7-18 ~]# ll test
-rw-r--r--. 1 root root 1000000 Jul 12 17:58 test
[root@centos7-18 ~]# ll -h test
-rw-r--r--. 1 root root 977K Jul 12 17:58 test

在这里插入图片描述

posted @ 2019-07-12 18:02  岳麓丹枫  阅读(498)  评论(0编辑  收藏  举报