There are a number of possible reasons you may want to create a file of a specific size. For example:
- Testing upload/download speed (you may want a very large file, for example)
- Testing edge conditions related to file size
- Test the behavior of a mix of large and small files
Probably one of the least complicated UNIX utilities every written is called mkfile and is designed for this purpose. It’s super simple to use:
mkfile <size> <filename>
For size, you just use a number, suffixed by b(bytes), k(kilobytes), m(megabytes), g(gigabytes). So, a specific example:
mkfile 10g TenGigabyte.txt
This creates a 10 gigabyte file called TenGigabyte.txt.
The files will all just be zeroes, but for many purposes, this is fine.