Creating Testfiles of Given Length

Use the Unix /dev/zero device (which produces an infinite stream of bytes with value zero) together with the dd block copier to create files of any length, useful for testing.

dd if=/dev/zero of=test.bin bs=1024\*1024 count=4

… creates a file called test.bin (output file) by copying from /dev/zero (input file). Blocksize is 1 MB (1024*1024 bytes), and the count is 4, giving a 4 MB file. Substitute your own values for blocksize and count, and create test files of any length.

  • Share/Bookmark
This entry was posted in Software Engineering and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>