Tip #787 Create a file of specific size
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).
- TAGS:
- dd
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs