Generate dummy files in bash

后端 未结 8 877
面向向阳花
面向向阳花 2021-02-01 17:08

I\'d like to generate dummy files in bash. The content doesn\'t matter, if it was random it would be nice, but all the same byte is also acceptable.

My first attempt was

8条回答
  •  遥遥无期
    2021-02-01 17:45

    If your file system is ext4, btrfs, xfs or ocfs2, and if you don't care about the content you can use fallocate. It's the fastest method if you need big files.

    fallocate -l 100KB dummy_100KB_file
    

    See "Quickly create a large file on a Linux system?" for more details.

提交回复
热议问题