Popular Posts

Tuesday, May 27, 2014

Create File of a Given Size

I was testing uuencode command and my plan was to create a 10M file and send it as a attachment.

below is the coolest way to do that :)


On Linux, you can use the dd command:

$ dd if=/dev/zero of=output.dat  bs=1024  count=10240
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.218581 seconds, 48.0 MB/s
$ ls -hl output.dat
-rw-r--r-- 1 peter peter 10M 2008-02-09 16:21 output.dat



The above dd command creates a zero-filled file named output.dat consisting of a count of 10240 blocks, each of block size 1024.

You can also do the same thing using :

$ dd if=/dev/zero of=output.dat  bs=1M  count=10


Suggestions are welcome!