//View Tip #787
Similar Tips
» Make an iso image of cd
» Wipe deleted files with dd
» Convert nrg to iso
» Connect your mic to a remote speaker
» MBR (Master Boot Record) backup & restore

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Recently I needed several files of certain sizes for testing the transfer speed between two machines. Files like this can easily be created with the dd command which lets you create an empty file of desired size.

$ dd if=/dev/zero of=dummy_file bs=1k count=2048
2048+0 records in
2048+0 records out
2097152 bytes (2.1 MB) copied, 0.0190557 s, 110 MB/s

$ ls -lh dummy_file
-rw-r--r-- 1 user group 2.0M 2009-05-11 10:05 dummy_file

/dev/zero is a special file that provides as many null characters (ASCII NUL, 0×00) as are read from it. In the above example, the bs option sets both input and output block size to 1k. The count option specifies 2048 input blocks, so that command will create a file (named dummy_file) with a size of 2MB (2048k).


View Comments »




Comments 

Add your comment

Comments are currently disabled
Amos Shapira
If you want to use these files for transfer speed over connections which might compress then you want a random content as the output of /dev/zero can be easily compressed.

You can get random content from /dev/urandom or if you are less worried about security then you can use one of the raw block devices under /dev/sd*, for instance.
Posted 2009-05-11 17:25:22
dave
Agreed - /dev/urandom is a better option for speed test sample files. A file consisting of 2M of null characters is easily compressible, and could exaggerate your connection speed.
Posted 2009-05-15 15:26:16
John
I knew that the transfer I was testing wasn't using any compression, so I was okay. Your point is a very good one though!
Posted 2009-05-15 15:34:27

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit