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