How to create a file with a given size in Linux?

后端 未结 13 1238
既然无缘
既然无缘 2020-11-28 17:57

For testing purposes I have to generate a file of a certain size (to test an upload limit).

What is a command to create a file of a certain size on Linux?

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 18:19

    Just to follow up Tom's post, you can use dd to create sparse files as well:

    dd if=/dev/zero of=the_file bs=1 count=0 seek=12345
    

    This will create a file with a "hole" in it on most unixes - the data won't actually be written to disk, or take up any space until something other than zero is written into it.

提交回复
热议问题