Solutions Log by Dan Reiland

13Aug/092

Create a Large File For Testing

Issue:
Often you need a set of variable sized files for testing a particular scenario. Generating test data is a painless endeavor.

Resolution:
The Unix dd command is perfectly suited to dispatch this need.

dd if=/dev/zero of=~/testfile.txt bs=1m count=5

The above command will create a 5 megabyte file full of zeroes. Lovely. You may adjust the count (or blocksize) to achieve the results you desire. This data also achieves stellar compression ratios based on its content.

One could also create a test file full of pseudo random data by pointing if to /dev/urandom.

dd if=/dev/urandom of=~/testfile.txt bs=1m count=5

Explanation of /dev/urandom

Comments (2) Trackbacks (0)
  1. You may also want to mention /dev/urandom, since in most cases test files need not be truly random, and using /dev/random can needlessly run down your system’s entropy.

  2. Excellent point. I have updated the post.


Leave a comment


No trackbacks yet.