Create a test file

written by justin on September 13th, 2007 @ 03:50 PM

Sometimes we need to create files of certain sizes to test certain functionality like mail attachment sizes or something similiar. On Mac OS X and probably about any unix variant you can use the dd command to create a nice test file of garbage or in this case nulls.


dd if=/dev/zero bs=1048576 count=20 of=big_file

The input source is /dev/zero, the block size is 1048576 bytes (1MB in other words) and the count of the blocks to write is 20, and the output file is called big_file. This produces a file of exactly 20MB for use in testing.


$ ls -lh big_file 
-rw-r--r--   1 username  groupname       20M Sep 13 16:03 big_file


Post a comment